You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2021-01-08 16:51:19

arthurock
Member
Registered: 2021-01-08
Posts: 3

Comment mettre à jour agent Fusion Inventory

Bonjour,
mon GLPI fonctionne vers 9.4 (je sais je dois le mettre à jour) mais d'abord je teste en proto puis je passerai sur la dernière version pour la prod.

pour le moment c'est un parc de 5 marchines avec des configs distinctes pour voir le fonctionnement des entités, lieux, règles ...

Le déploiement fonctionne sur des choses basiques de création de répertoires, fichiers ..

Le parc n'est pas géré par AD, pas de GPO

Au niveau des postes des différents agents V 2.4.2, 2.5.2 et 2.6

1/Je n'ai pas trouvé d'option pour faire une mise à jour de l'agent de façon automatique (==> je pense que cela a du être remonté et cela serait bien)

2/comment faire la mise à jour car je n'ai pas réussi

voici le script vbs qui est bien copié dans le répertoire du win10
j'ai juste retirer l'adresse du serveur et j'ai mis monsite dans le script ci-dessous.
ce script fonctionne quand je l'exécute en local.
il détecte l'architecture et va chercher la V2.6 sur github puis exécute avec les différentes options en silencieux

'
'  ------------------------------------------------------------------------
'  fusioninventory-agent-deployment.vbs
'  Copyright (C) 2010-2017 by the FusionInventory Development Team.
'
'  http://www.fusioninventory.org/ http://forge.fusioninventory.org/
'  ------------------------------------------------------------------------
'
'  LICENSE
'
'  This file is part of FusionInventory project.
'
'  This file is free software; you can redistribute it and/or modify it
'  under the terms of the GNU General Public License as published by the
'  Free Software Foundation; either version 2 of the License, or (at your
'  option) any later version.
'
'
'  This file is distributed in the hope that it will be useful, but WITHOUT
'  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
'  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
'  more details.
'
'  You should have received a copy of the GNU General Public License
'  along with this program; if not, write to the Free Software Foundation,
'  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA,
'  or see <http://www.gnu.org/licenses/>.
'
'  ------------------------------------------------------------------------
'
'  @package   FusionInventory Agent
'  @file      .\contrib\windows\fusioninventory-agent-deployment.vbs
'  @author(s) Benjamin Accary <meldrone@orange.fr>
'             Christophe Pujol <chpujol@gmail.com>
'             Marc Caissial <marc.caissial@zenitique.fr>
'             Tomas Abad <tabadgp@gmail.com>
'             Guillaume Bougard <gbougard@teclib.com>
'  @copyright Copyright (c) 2010-2017 FusionInventory Team
'  @license   GNU GPL version 2 or (at your option) any later version
'             http://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
'  @link      http://www.fusioninventory.org/
'  @link      http://forge.fusioninventory.org/projects/fusioninventory-agent
'  @since     2012
'
'  ------------------------------------------------------------------------
'

'
'
' Purpose:
'     FusionInventory Agent Unatended Deployment.
'
'

Option Explicit
Dim Force, Verbose
Dim Setup, SetupArchitecture, SetupLocation, SetupOptions, SetupVersion

Dim TAG 

TAG = "SITE-XX"
'
'
' USER SETTINGS
'
'

' SetupVersion
'    Setup version with the pattern <major>.<minor>.<release>[-<package>]
'
SetupVersion = "2.6"

' SetupLocation
'    Depending on your needs or your environment, you can use either a HTTP or
'    CIFS/SMB.
'
'    If you use HTTP, please, set to SetupLocation a URL:
'
'       SetupLocation = "http://host[:port]/[absolut_path]" or
'       SetupLocation = "https://host[:port]/[absolut_path]"
'
'    If you use CIFS, please, set to SetupLocation a UNC path name:
'
'       SetupLocation = "\\host\share\[path]"
'
'       You also must be sure that you have removed the "Open File Security Warning"
'       from programs accessed from that UNC.
'
' Location for Release Candidates
' SetupLocation = "https://github.com/TECLIB/fusioninventory-agent-windows-installer/releases/download/" & SetupVersion
SetupLocation = "https://github.com/fusioninventory/fusioninventory-agent/releases/download/" & SetupVersion


' SetupArchitecture
'    The setup architecture can be 'x86', 'x64' or 'Auto'
'
'    If you set SetupArchitecture = "Auto" be sure that both installers are in
'    the same SetupLocation.
'
SetupArchitecture = "Auto"

' SetupOptions
'    Consult the installer documentation to know its list of options.
'
'    You should use simple quotes (') to set between quotation marks those values
'    that require it; double quotes (") doesn't work with UNCs.
'



SetupOptions = "/acceptlicense /installtasks=Full /runnow /add-firewall-exception /execmode=Service /no-start-menu /httpd-trust='127.0.0.1/32' /server='http://monsite/plugins/fusioninventory/' /tag='" & TAG & "' /S"

' Setup
'    The installer file name. You should not have to modify this variable ever.
'
Setup = "fusioninventory-agent_windows-" & SetupArchitecture & "_" & SetupVersion & ".exe"

' Force
'    Force the installation even whether Setup is previously installed.
'
Force = "Yes"

' Verbose
'    Enable or disable the information messages.
'
'    It's advisable to use Verbose = "Yes" with 'cscript //nologo ...'.
'
Verbose = "Yes"

'
'
' DO NOT EDIT BELOW
'
'

Function AdvanceTime(nMinutes)
   Dim nMinimalMinutes, dtmTimeFuture
   ' As protection
   nMinimalMinutes = 5
   If nMinutes < nMinimalMinutes Then
      nMinutes = nMinimalMinutes
   End If
   ' Add nMinutes to the current time
   dtmTimeFuture = DateAdd ("n", nMinutes, Time)
   ' Format the result value
   '    The command AT accepts 'HH:MM' values only
   AdvanceTime = Hour(dtmTimeFuture) & ":" & Minute(dtmTimeFuture)
End Function

Function baseName (strng)
   Dim regEx, ret
   Set regEx = New RegExp
   regEx.Global = true
   regEx.IgnoreCase = True
   regEx.Pattern = ".*[/\\]([^/\\]+)$"
   baseName = regEx.Replace(strng,"$1")
End Function

Function GetSystemArchitecture()
   Dim strSystemArchitecture
   Err.Clear
   ' Get operative system architecture
   On Error Resume Next
   strSystemArchitecture = CreateObject("WScript.Shell").ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%")
   If Err.Number = 0 Then
      ' Check the operative system architecture
      Select Case strSystemArchitecture
         Case "x86"
            ' The system architecture is 32-bit
            GetSystemArchitecture = "x86"
         Case "AMD64"
            ' The system architecture is 64-bit
            GetSystemArchitecture = "x64"
         Case Else
            ' The system architecture is not supported
            GetSystemArchitecture = "NotSupported"
      End Select
   Else
      ' It has been not possible to get the system architecture
      GetSystemArchitecture = "Unknown"
   End If
End Function

Function isHttp(strng)
   Dim regEx, matches
   Set regEx = New RegExp
   regEx.Global = true
   regEx.IgnoreCase = True
   regEx.Pattern = "^(http(s?)).*"
   If regEx.Execute(strng).count > 0 Then
      isHttp = True
   Else
      isHttp = False
   End If
   Exit Function
End Function

Function IsInstallationNeeded(strSetupVersion, strSetupArchitecture, strSystemArchitecture)
   Dim strCurrentSetupVersion
   ' Compare the current version, whether it exists, with strSetupVersion
   If strSystemArchitecture = "x86" Then
      ' The system architecture is 32-bit
      ' Check if the subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent' exists
      '    This subkey is now deprecated
      On error resume next
      strCurrentSetupVersion = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion")
      If Err.Number = 0 Then
      ' The subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent' exists
         If strCurrentSetupVersion <> strSetupVersion Then
            ShowMessage("Installation needed: " & strCurrentSetupVersion & " -> " & strSetupVersion)
            IsInstallationNeeded = True
         End If
         Exit Function
      Else
         ' The subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent' doesn't exist
         Err.Clear
         ' Check if the subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' exists
         On error resume next
         strCurrentSetupVersion = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent\DisplayVersion")
         If Err.Number = 0 Then
         ' The subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' exists
            If strCurrentSetupVersion <> strSetupVersion Then
               ShowMessage("Installation needed: " & strCurrentSetupVersion & " -> " & strSetupVersion)
               IsInstallationNeeded = True
            End If
            Exit Function
         Else
            ' The subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' doesn't exist
            Err.Clear
            ShowMessage("Installation needed: " & strSetupVersion)
            IsInstallationNeeded = True
         End If
      End If
   Else
      ' The system architecture is 64-bit
      ' Check if the subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent' exists
      '    This subkey is now deprecated
      On error resume next
      strCurrentSetupVersion = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion")
      If Err.Number = 0 Then
      ' The subkey 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent' exists
         If strCurrentSetupVersion <> strSetupVersion Then
            ShowMessage("Installation needed: " & strCurrentSetupVersion & " -> " & strSetupVersion)
            IsInstallationNeeded = True
         End If
         Exit Function
      Else
         ' The subkey 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent' doesn't exist
         Err.Clear
         ' Check if the subkey 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' exists
         On error resume next
         strCurrentSetupVersion = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent\DisplayVersion")
         If Err.Number = 0 Then
         ' The subkey 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' exists
            If strCurrentSetupVersion <> strSetupVersion Then
               ShowMessage("Installation needed: " & strCurrentSetupVersion & " -> " & strSetupVersion)
               IsInstallationNeeded = True
            End If
            Exit Function
         Else
            ' The subkey 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' doesn't exist
            Err.Clear
            ' Check if the subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' exists
            On error resume next
            strCurrentSetupVersion = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent\DisplayVersion")
            If Err.Number = 0 Then
            ' The subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' exists
               If strCurrentSetupVersion <> strSetupVersion Then
                  ShowMessage("Installation needed: " & strCurrentSetupVersion & " -> " & strSetupVersion)
                  IsInstallationNeeded = True
               End If
               Exit Function
            Else
               ' The subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' doesn't exist
               Err.Clear
               ShowMessage("Installation needed: " & strSetupVersion)
               IsInstallationNeeded = True
            End If
         End If
      End If
   End If
End Function

Function IsSelectedForce()
   If LCase(Force) <> "no" Then
      ShowMessage("Installation forced: " & SetupVersion)
      IsSelectedForce = True
   Else
      IsSelectedForce = False
   End If
End Function

' http://www.ericphelps.com/scripting/samples/wget/index.html
Function SaveWebBinary(strSetupLocation, strSetup)
   Const adTypeBinary = 1
   Const adSaveCreateOverWrite = 2
   Const ForWriting = 2
   Dim web, varByteArray, strData, strBuffer, lngCounter, ado, strUrl
   strUrl = strSetupLocation & "/" & strSetup
   'On Error Resume Next
   'Download the file with any available object
   Err.Clear
   Set web = Nothing
   Set web = CreateObject("WinHttp.WinHttpRequest.5.1")
   If web Is Nothing Then Set web = CreateObject("WinHttp.WinHttpRequest")
   If web Is Nothing Then Set web = CreateObject("MSXML2.ServerXMLHTTP")
   If web Is Nothing Then Set web = CreateObject("Microsoft.XMLHTTP")
   web.Open "GET", strURL, False
   web.Send
   If Err.Number <> 0 Then
      SaveWebBinary = False
      Set web = Nothing
      Exit Function
   End If
   If web.Status <> "200" Then
      SaveWebBinary = False
      Set web = Nothing
      Exit Function
   End If
   varByteArray = web.ResponseBody
   Set web = Nothing
   'Now save the file with any available method
   On Error Resume Next
   Set ado = Nothing
   Set ado = CreateObject("ADODB.Stream")
   If ado Is Nothing Then
      Set fs = CreateObject("Scripting.FileSystemObject")
      Set ts = fs.OpenTextFile(baseName(strUrl), ForWriting, True)
      strData = ""
      strBuffer = ""
      For lngCounter = 0 to UBound(varByteArray)
         ts.Write Chr(255 And Ascb(Midb(varByteArray,lngCounter + 1, 1)))
      Next
      ts.Close
   Else
      ado.Type = adTypeBinary
      ado.Open
      ado.Write varByteArray
      ado.SaveToFile CreateObject("WScript.Shell").ExpandEnvironmentStrings("%TEMP%") & "\" & strSetup, adSaveCreateOverWrite
      ado.Close
   End If
   SaveWebBinary = True
End Function

Function ShowMessage(strMessage)
   If LCase(Verbose) <> "no" Then
      WScript.Echo strMessage
   End If
End Function

'
'
' MAIN
'
'

Dim nMinutesToAdvance, strCmd, strSystemArchitecture, strTempDir, WshShell
Set WshShell = WScript.CreateObject("WScript.shell")

nMinutesToAdvance = 5

' Get system architecture
strSystemArchitecture = GetSystemArchitecture()
If (strSystemArchitecture <> "x86") And (strSystemArchitecture <> "x64") Then
   ShowMessage("The system architecture is unknown or not supported.")
   ShowMessage("Deployment aborted!")
   WScript.Quit 1
Else
   ShowMessage("System architecture detected: " & strSystemArchitecture)
End If

' Check and auto detect SetupArchitecture
Select Case LCase(SetupArchitecture)
   Case "x86"
      ' The setup architecture is 32-bit
      SetupArchitecture = "x86"
      Setup = Replace(Setup, "x86", SetupArchitecture, 1, 1, vbTextCompare)
      ShowMessage("Setup architecture: " & SetupArchitecture)
   Case "x64"
      ' The setup architecture is 64-bit
      SetupArchitecture = "x64"
      Setup = Replace(Setup, "x64", SetupArchitecture, 1, 1, vbTextCompare)
      ShowMessage("Setup architecture: " & SetupArchitecture)
   Case "auto"
      ' Auto detection of SetupArchitecture
      SetupArchitecture = strSystemArchitecture
      Setup = Replace(Setup, "Auto", SetupArchitecture, 1, 1, vbTextCompare)
      ShowMessage("Setup architecture detected: " & SetupArchitecture)
   Case Else
      ' The setup architecture is not supported
      ShowMessage("The setup architecture '" & SetupArchitecture & "' is not supported.")
      WScript.Quit 2
End Select

' Check the relation between strSystemArchitecture and SetupArchitecture
If (strSystemArchitecture = "x86") And (SetupArchitecture = "x64") Then
   ' It isn't possible to execute a 64-bit setup on a 32-bit operative system
   ShowMessage("It isn't possible to execute a 64-bit setup on a 32-bit operative system.")
   ShowMessage("Deployment aborted!")
   WScript.Quit 3
End If

If IsSelectedForce() Or IsInstallationNeeded(SetupVersion, SetupArchitecture, strSystemArchitecture) Then
   If isHttp(SetupLocation) Then
      ShowMessage("Downloading: " & SetupLocation & "/" & Setup)
      If SaveWebBinary(SetupLocation, Setup) Then
         strCmd = WshShell.ExpandEnvironmentStrings("%ComSpec%")
         strTempDir = WshShell.ExpandEnvironmentStrings("%TEMP%")
         ShowMessage("Running: """ & strTempDir & "\" & Setup & """ " & SetupOptions)
         WshShell.Run """" & strTempDir & "\" & Setup & """ " & SetupOptions, 0, True
         ShowMessage("Scheduling: DEL /Q /F """ & strTempDir & "\" & Setup & """")
         WshShell.Run "AT.EXE " & AdvanceTime(nMinutesToAdvance) & " " & strCmd & " /C ""DEL /Q /F """"" & strTempDir & "\" & Setup & """""", 0, True
         ShowMessage("Deployment done!")
      Else
         ShowMessage("Error downloading '" & SetupLocation & "\" & Setup & "'!")
      End If
   Else
      ShowMessage("Running: """ & SetupLocation & "\" & Setup & """ " & SetupOptions)
      WshShell.Run "CMD.EXE /C """ & SetupLocation & "\" & Setup & """ " & SetupOptions, 0, True
      ShowMessage("Deployment done!")
   End If
Else
   ShowMessage("It isn't needed the installation of '" & Setup & "'.")
End If

ci-dessous le contenu de l'exécution de déploiement :

2021-01-08 15:05:23	En cours d'exécution	Actions:action #3, processing success
2021-01-08 15:05:23	En cours d'exécution	Actions:action #3: ok, no check to evaluate.
2021-01-08 15:05:23	En cours d'exécution	Actions:action #3: exit status: `0'
2021-01-08 15:05:23	En cours d'exécution	Actions:action #3: --------------------------------
2021-01-08 15:05:22	En cours d'exécution	Actions:action #3: c:\fusion>exit 0
2021-01-08 15:05:22	En cours d'exécution	Actions:action #3:
2021-01-08 15:05:22	En cours d'exécution	Actions:action #3: C:\Program Files\FusionInventory-Agent\var\http..__monsite_plugins_fusioninventory_\deploy\workdir\5ff866179579d>cd c:\fusion
2021-01-08 15:05:22	En cours d'exécution	Actions:action #3:
2021-01-08 15:05:22	En cours d'exécution	Actions:action #3: C:\Program Files\FusionInventory-Agent\perl\bin>cd "C:\Program Files\FusionInventory-Agent\var\http..__monsite_plugins_fusioninventory_\deploy\workdir\5ff866179579d"
2021-01-08 15:05:22	En cours d'exécution	Actions:action #3:
2021-01-08 15:05:22	En cours d'exécution	Actions:action #3: ================================
2021-01-08 15:05:21	En cours d'exécution	Actions:action #3: Started cmd: cd c:\fusion
2021-01-08 15:05:21	En cours d'exécution	Actions:action #3: ================================
2021-01-08 15:05:21	En cours d'exécution	Actions:copie des fichiers, processing success
2021-01-08 15:05:21	En cours d'exécution	Actions:Création Répertoire FusionInventory, processing success
2021-01-08 15:05:21	En cours d'exécution	Actions:Création Répertoire FusionInventory: Directory c:\fusion already exists
2021-01-08 15:05:21	En cours d'exécution	Préparation des fichiers:success
2021-01-08 15:05:20	En cours d'exécution	Téléchargement de fichiers:success
2021-01-08 15:05:20	En cours d'exécution	Téléchargement de fichiers:fusioninventory.vbs downloaded
2021-01-08 15:05:20	En cours d'exécution	Téléchargement de fichiers:fetching fusioninventory.vbs
2021-01-08 15:05:20	En cours d'exécution	Téléchargement de fichiers:downloading files
2021-01-08 15:05:20	En cours d'exécution	Audits:all checks are ok
2021-01-08 15:05:19	En cours d'exécution	Audits:starting
2021-01-08 15:03:01	Préparé	

le code du déploiement de paquet est le suivant :

- Créer un répertoire
c:\fusion name Création Répertoire FusionInventory
- Copier
from * to c:\fusion\ name copie des fichiers
- Commande
Commande à exécuter
cd c:\fusion
name logLineLimit 80
-Commande
Commande à exécuter
fusioninventory.vbs
name logLineLimit 100

Merci de vos retours

Offline

#2 2021-01-27 16:39:10

Zeyko
Member
Registered: 2021-01-27
Posts: 1

Re: Comment mettre à jour agent Fusion Inventory

Bonjour,

Je ne sais pas si je viens de trop tard ou pas mais voici le scipt utilisé pour mettre à jour les agents de mon parc ;
Contexte : Les agents étaient en 2.1, le script a été déployer sur SCCM, via un script qui lance le VBS.
L'agent fusion est stocker sur un partage de l'AD.

Script :

'
' FusionInventory-Deploy.vbs
'
' Use this script to automatically
'     - install FusionInventory-Agent
'     - upgrade from version 2.1 to 2.5.2
'     
'
' You can run this script manually or use it as a startup script in a computer policy in an Active Directoy forest
'
' Just put the path to fusioninventory-agent_windows-i386_2.5.2.x.exe in the "FusionSetupExe" variable,
'     and set the other variables in the USER SETTINGS section
'
' Versions :
'     2012-11-22 : initial
'     2012-11-26 : added upgrade from version 2.1 & more comments
'     2013-01-09 : updated the displayed messages
'     2013-02-18 : display messages only if IsVerbose is True (for silent use in GPO with /S parameter)
'     2013-04-25 : delete Start Menu item if /D parameter is used ; display usage with /? or /H parameter
'     2021-01-08 : Change FusionArguments and refresh line for version 	9.5.2
'     
'
' Author : Marc Caissial <contact@zenitique.fr>
' Modified by ANTOINE Baptiste and STEIN Killian
'
' My thanks to the authors of the "fusioninventory.vbs" script on the documentation page
' and to Tomas Abad <tabad@sescam.jccm.es> for his Resources kit for massive and unattended tasks
' that I found on the FusionInventory Forge, and that I used in my upgrade part
'
'
Option Explicit
On Error Resume Next
Dim AvailableVersion, InstalledVersion, FusionArguments, UpdateArguments, FusionSetupExe, WshShell, wshFSO, OSType, InstallCommand, UpdateCommand, StopSvcCommand, StartSvcCommand, UninstallCommand, InstalledKey, UninstallKey, strArg,IsVerbose, DeleteStartMenuItem, StartMenuItemFile
'
' USER SETTINGS
'
AvailableVersion = "2.5.2"
FusionArguments = "/S /acceptlicense /runnow /server='http://your.glpi.address/plugins/fusioninventory/'"
UpdateArguments = "/execmode=none"
FusionSetupExe = "\\directory_fusion\fusion_inventory\fusioninventory-agent_windows-x86_" & AvailableVersion & ".exe"
'
' DO NOT EDIT BELOW
'

' Process command line arguments
IsVerbose = True
DeleteStartMenuItem = False
if wscript.Arguments.length >= 1 then
    for each strArg in wscript.Arguments
        if strArg = "/s" or strArg = "/S" then IsVerbose = False
        if strArg = "/d" or strArg = "/D" then DeleteStartMenuItem = True
        if strArg = "/h" or strArg = "/H" or strArg = "/?" then
            wscript.Echo "Usage : " & wscript.ScriptName & " [/S] [/D] [/h]" & vbCrLf & "    /S : Run in Silent Mode" & vbCrLf & "    /D : Delete the ""FusionInventory Status"" item in the Start Menu" & vbCrLf & "    /H : Display this help message and quit"
            wscript.quit
        end if
    next
end if

InstallCommand = FusionSetupExe & " " & FusionArguments
UpdateCommand = InstallCommand & " " & UpdateArguments
StopSvcCommand = "SC STOP ""FusionInventory-Agent"""
StartSvcCommand = "SC START ""FusionInventory-Agent"""

set WshShell = Wscript.CreateObject("Wscript.shell")
StartMenuItemFile = wshShell.SpecialFolders("AllUsersPrograms") & "\FusionInventory Status.url"

' Get OS Type, 32 or 64 bit
OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")

' Extract installed version & uninstall command from registry
if (OsType = "x86") then
    InstalledKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion"
    UninstallKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\UninstallString"
else
    InstalledKey = "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion"
    UninstallKey = "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\UninstallString"
end if

' Install FusionInventory-Agent if not yet installed
' If migrating from 2.1 to 2.5.2, first uninstall 2.1, then install 2.5.2
' Update FusionInventory if available version is newer than installed one

InstalledVersion = WshShell.RegRead(InstalledKey)
UninstallCommand = """" & WshShell.RegRead(UninstallKey) & """ /S"

' FusionInventory-Agent not yet installed, so install it
if InstalledVersion = "" then
    if IsVerbose then Wscript.Echo "FusionInventory-Agent not installed, installing v. " & AvailableVersion & "..."
    'Wscript.Echo "Running command: " & InstallCommand
    WshShell.Run "CMD.EXE /C """ & InstallCommand & """",0,True

' Upgrade from version 2.1 to version 2.5.2
' Must uninstall version 2.1 first, then install version 2.5.2
elseif InstalledVersion < "2.3" and AvailableVersion > "2.3" then
    if IsVerbose then Wscript.Echo "Uninstalling FusionInventory-Agent v. " & InstalledVersion & " & upgrading to v. " & AvailableVersion & "..."
    'Wscript.Echo "Running commands:" & vbCrLf & "   " & StopSvcCommand & vbCrLf & "   " & UninstallCommand & vbCrLf & "   " & InstallCommand
    ' Stop the FusioInventory-Agent service
    WshShell.Run "CMD.EXE /C """ & StopSvcCommand & """",0,True
    ' Wait 5 seconds
    WScript.Sleep (5 * 1000)
    ' Uninstal the agent
    WshShell.Run "CMD.EXE /C """ & Uninstallcommand & """",0,True
    ' Wait 30 seconds
    WScript.Sleep (30 * 1000)
    ' Install new version of the agent
    WshShell.Run "CMD.EXE /C """ & InstallCommand & """",0,True

' Update from version 2.5.2.x to version 2.5.2.y if y > x, then restart service
elseif InstalledVersion < AvailableVersion then
    if IsVerbose then Wscript.Echo "Updating FusionInventory-Agent v." & InstalledVersion & " to new v." & AvailableVersion & "..."
    ' Stop the FusioInventory-Agent servive
    WshShell.Run "CMD.EXE /C """ & StopSvcCommand & """",0,True
    ' Wait 5 seconds
    WScript.Sleep (5 * 1000)
    'Wscript.Echo "Running command: " & UpdateCommand
    WshShell.Run "CMD.EXE /C """ & UpdateCommand & """",0,True
    ' Wait 5 seconds
    WScript.Sleep (5 * 1000)
    ' Start the FusioInventory-Agent servive
    WshShell.Run "CMD.EXE /C """ & StartSvcCommand & """",0,True

' Nothing to do
else
    if IsVerbose then Wscript.Echo "Current FusionInventory-Agent v." & InstalledVersion & " is up to date."
end if

' Delete "FusionInventory Status" Start Menu item
if DeleteStartMenuItem then
    set wshFSO = CreateObject("Scripting.FileSystemObject")
    if wshFSO.FileExists (StartMenuItemFile) then
        if IsVerbose then wscript.echo "File """ & StartMenuItemFile & """ deleted."
        wshFSO.DeleteFile StartMenuItemFile, true
    else
    if IsVerbose then wscript.echo "File """ & StartMenuItemFile & """ doesn't exist."
    end if
end if

'Done
if IsVerbose then Wscript.Echo "End of FusionInventory-Agent v." & AvailableVersion & " deployment." & VbCrLf

Merci de votre retour

Bonne journée

Cordialement

Offline

#3 2021-01-27 18:47:11

arthurock
Member
Registered: 2021-01-08
Posts: 3

Re: Comment mettre à jour agent Fusion Inventory

Merci du retour, je vais tenter le script

Cdt

Offline

#4 2021-06-08 11:21:16

Mohamed-kone
Member
From: GB
Registered: 2020-09-28
Posts: 3

Re: Comment mettre à jour agent Fusion Inventory

Bonjour Zeyko, j'ai utilisé votre script qui s'installe correctement sur les machines du réseau mais elles ne sont pas visites dans l'inventaire.
L'agent s'installe sur les postes mais aucun service FusionInventory Agent n'est installé; ce qui fait que les machines n'arrivent pas à contacter le serveur;

Peux-tu me donner un coup de main stp ?

Offline

Board footer

Powered by FluxBB