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 2016-08-26 09:08:38

patrick.lassabliere
Member
Registered: 2016-06-28
Posts: 16

deploiement de l'agent par script VBS

Bonjour

J'ai mis en place le déploiement de l'agent fusion inventory par GPO.

Serveur GLPI windows 2008 r2.

Fichier VBS:
Option Explicit
On Error Resume Next
Dim AvailableVersion, InstalledVersion23, InstalledVersion22, TagArg, ServerArg, InstallArg, StartMenuArg, FusionSetupLocation, WshShell, wshFSO, OSType, InstallCommand, InstalledKeyV23, InstalledKeyV22, UninstallKeyV22, UninstallCommandV22, strArg, IsVerbose
'
' USER SETTINGS
'
AvailableVersion = "2.3.17"
TagArg = ""
ServerArg="http://infoservglpi/glpi/plugins/fusioninventory/"
InstallArg = "/S /acceptlicense /add-firewall-exception /installtasks=Full /runnow /execmode=Service"
StartMenuArg = "/no-start-menu"
FusionSetupLocation = "\\vmadfeurs\deployGlpi\FusionInventory"
'
' DO NOT EDIT BELOW
'

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

set WshShell = Wscript.CreateObject("Wscript.shell")

' 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
    InstalledKeyV23 = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent\DisplayVersion"
    InstalledKeyV22 = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion"
    UninstallKeyV22 = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\UninstallString"
else
    OsType = "x64"
    InstalledKeyV23 = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent\DisplayVersion"
    InstalledKeyV22 = "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion"
    UninstallKeyV22 = "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\UninstallString"
end if

' Install, update or upgrade FusionInventory-Agent

InstalledVersion23 = WshShell.RegRead(InstalledKeyV23)
InstalledVersion22 = WshShell.RegRead(InstalledKeyV22)
UninstallCommandV22 = """" & WshShell.RegRead(UninstallKeyV22) & """ /S"
InstallCommand = FusionSetupLocation & "\fusioninventory-agent_windows-" & OsType & "_" & AvailableVersion & ".exe " & TagArg & " /server='" & ServerArg & "' " & InstallArg & " " & StartMenuArg

' FusionInventory-Agent not yet installed, so install it
if InstalledVersion22 = "" and InstalledVersion23 = "" 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.2 to version 2.3
elseif InstalledVersion22 > "2.2" then
    if IsVerbose then Wscript.Echo "Upgrading FusionInventory-Agent v." & InstalledVersion22 & " to new v." & AvailableVersion & "..."
    'Uninstall version 2.2
    ' Stop the FusioInventory-Agent service
    WshShell.Run "CMD.EXE /C ""SC STOP FusionInventory-Agent""",0,True
    ' Wait 5 seconds
    WScript.Sleep (5 * 1000)
    ' Uninstal the agent
    WshShell.Run "CMD.EXE /C """ & UninstallcommandV22 & """",0,True
    ' Wait 30 seconds
    WScript.Sleep (30 * 1000)
    'Wscript.Echo "Running command: " & InstallCommand
    WshShell.Run "CMD.EXE /C """ & InstallCommand & """",0,True

' Update from version 2.3.x to version 2.3.y if y > x
elseif InstalledVersion23 < AvailableVersion then
    if IsVerbose then Wscript.Echo "Updating FusionInventory-Agent v." & InstalledVersion23 & " to new v." & AvailableVersion & "..."
    'Wscript.Echo "Running command: " & InstallCommand
    WshShell.Run "CMD.EXE /C """ & InstallCommand & """",0,True

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

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

La GPO se lance bien mais je ne retrouve pas le répertoire de l'agent sur les postes concernés et lorsque je lance manuellement le fichier fusioninventory-agent_windows-x64_2.3.17.exe j'ai la case installer avec la configuration actuelle qui est cochée ce qui indique que l'agent est déja installé.

Offline

Board footer

Powered by FluxBB