Szukaj na tym blogu

piątek, 1 kwietnia 2016

SCCM application detection method - PowerShell script

I had a situation that we need to run application on workstations (Lenovo ThinInstaller) which install drivers for specific computer model. So it is hard to determine whether this application was run\finished success or not (it is not installed by itself). This application can generate text log file so we decided to build SCCM application detection method based on content of this log file

if (test-path C:\Lenovothinistall.txt) {
$zmienna = gc C:\Lenovothinistall.txt | Select-String "Installation succeeded"
if ($zmienna -ne $null) {write-host "ok"}
}
if (test-path C:\Lenovothinistall.txt) {
$zmienna1 = gc C:\Lenovothinistall.txt | Select-String "Return0Updates"
if ($zmienna1 -ne $null) {write-host "ok"}
}

In such detection method the most important is that PowerShell script should always return 0. SCCM determine whether application was installed successfully or not based on stdout - which in above example is achieved by write-host cmdlet.
More details about this here http://blog.kloud.com.au/2014/08/12/powershell-detection-method-for-sccm-2012-application-compliance-management/

Brak komentarzy:

Prześlij komentarz