This is the PS code to silently install the Acrobat Reader. I have also added event and local logging, just as demonstrated logging segments.
Code
#define variables $strUser = "SCCM" $appSetup = "setup.exe" $silent = "" $Source = "Acrobat Reader 15.010.20056" $TimeFormat = 'yyyy/MM/dd hh:mm:ss tt' #create event log source new-eventlog -Logname Application -source $Source -ErrorAction SilentlyContinue $logstamp = (get-date).toString($TimeFormat) ; $logstamp + " Created event log source.">>log.txt #install application Clear-Host Write-Host "Starting Setup..." cmd /c ($appSetup + $silent) $logstamp = (get-date).toString($TimeFormat) ; $logstamp + " Launched setup.">>log.txt $logstamp = (get-date).toString($TimeFormat) ; $logstamp + " Exit code: " + $LastExitCode>>log.txt If ($LastExitCode -eq 0) { #write event log Clear-Host Write-Host "Writing event log..." $startTime = Get-date $startLog = $strUser + ': ' + $Source + ' COMPLETED SUCCESSFULLY ' + $startTime Write-Eventlog -Logname Application -Message $startLog -Source $Source -id 777 -entrytype Information -Category 0 $logstamp = (get-date).toString($TimeFormat) ; $logstamp + " Installed successfully!">>log.txt #exiting Clear-Host Write-Host "Installed successfully! Exiting now..." Start-Sleep -s 4 $logstamp = (get-date).toString($TimeFormat) ; $logstamp + " Exiting...">>log.txt } Else { #write event log Clear-Host Write-Host "Writing event log..." $startTime = Get-date $startLog = $strUser + ': ' + $Source + ' FAILED SETUP ' Write-Eventlog -Logname Application -Message $startLog -Source $Source -id 777 -entrytype Information -Category 0 $logstamp = (get-date).toString($TimeFormat) ; $logstamp + " Failed setup!">>log.txt #exiting Clear-Host Write-Host "Failed setup! Exiting now..." Start-Sleep -s 4 $logstamp = (get-date).toString($TimeFormat) ; $logstamp + " Exiting...">>log.txt }
The wrapper or launch file
This can be used as the main deploy script to wrap and deploy through desktop management software (i.e., SCCM, LANDesk, Altiris, etc.). This should be compiled into one, nice EXE with the resource files.
Code
@echo on title SCCM Installation color 0b cls set CurDir=%CD% set PSPath=C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe set Timer=ping -n 2 127.0.0.1 %PSPath% -Command "Set-ExecutionPolicy RemoteSigned" %PSPath% -file "%CurDir%\script.ps1" %Timer%>nul exit /b 0
List of package source files
abcpy.ini
AcroRdrDCUpd1501020056.msp
AcroRead.msi
AcroRead.mst (made using customization wizard)
Data1.cab
setup.exe
setup.ini
script.ps1 (the PS script from above)
sequence.cmd (the shell script from above)