Skip to content

Instantly share code, notes, and snippets.

@atao
Last active November 29, 2016 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atao/f15e377ac9ee78f2e71668ebe95105cc to your computer and use it in GitHub Desktop.
Save atao/f15e377ac9ee78f2e71668ebe95105cc to your computer and use it in GitHub Desktop.
Script d'installation de l'agent OCS Inventory pour un déploiement via GPO
##############################
# Installation OCS via GPO #
##############################
#Auteur : atao
#Date : 29/11/2016
#Chemin du fichier d'Installation
$executable = "\\[Chemin réseau de l'executable]\OCS-NG-Windows-Agent-Setup.exe"
#Récupération de la version du fichier
$version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($executable).FileVersion
#Arguments pour l'installation
$arguments = "/S /NOSPLASH /SERVER=https://[adresse du glpi].lan/ocsinventory/ /ssl=0 /force /NOW"
#Numéro de version si installé
$ocs = Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion | ? {$_.DisplayName -like "OCS Inventory NG Agent*"}
#Lancer OCS
$run_ocs = "C:\Program Files (x86)\OCS Inventory Agent\OcsSystray.exe"
#Installation
if ($ocs.DisplayVersion -ne $version){
Write "Début de l'installation..."
Start-Process $executable $arguments
While ((Test-Path $run_ocs) -eq $False){
Write "Attente de la fin de l'installation..."
sleep(8)
}
#Lancerment d'OCS
Start-Process $run_ocs
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment