PowerShell – install Adobe Reader

Remote deployment of Adobe Reader on multiple hosts without SCCM, GPO’s and other facilitators.

#-------------[deklarations]--------------------------
#source
$computers=Get-Content '\\host\shares\!scripts\!source\!computers.txt'
#logs
$successLog='\\host\shares\!scripts\!logs\done.LOG'
$errorLog='\\host\shares\!scripts\!logs\error.LOG'
$unreachableLog='\\host\shares\!scripts\!logs\unreachable.LOG'
#params
$source='\\host\shares\!install\adobe\'
$destination='c$\install\adobe\'
foreach($computer in $computers) {
    if(Test-Connection -ComputerName $computer -Count 1 -Quiet) {
        Try {
            Write-host "Copying files: $computer" -foreground 'gray'
            Copy-Item -Path $source -Destination \\$computer\$destination -Force -Recurse
            Write-host "Installation: $computer" -foreground 'gray'
            Invoke-Command -computerName $computer -ScriptBlock {powershell.exe c:\install\adobe\AcroRdr.exe /sAll /rs /norestart ALLUSERS=1 EULA_ACCEPT=YES}
            
            Write-host "updated: $computer" -foreground 'green'
            $computer >> $successLog
        } Catch {
            Write-host "error: $computer" -foreground 'red'
            $computer >> $errorLog<br> 
        } 
    } else {
        Write-host "offline: $computer" -foreground 'yellow'
        $computer >> $unreachableLog
    }
}
#-------------krolaki.eu--------------------------

Leave a Reply

Your email address will not be published. Required fields are marked *