This is a script I wrote to remotely install patches on servers. The servers.txt contains the server names (I used IP addresses). You will need psexec and appropriate access to the servers.
Clear-Host $ErrorActionPreference = 'silentlycontinue' $LocalHotFixPath = 'D:\Patches\' $SvrList = Get-Content 'D:\Patches\servers.txt' $HotFixes = @( # seperate KBs using commas 'KB4499175-x64.msu' ) foreach ($Server in $SvrList) { $Reboot = $False $RemoteHotFixPath = "\\$Server\c$\Windows\Temp\" # Install each hotfix foreach ($HotFix in $HotFixes) { Write-Host "Processing $HotFix on $Server..." $HotFixPath = "$LocalHotFixPath$HotFix" # Copy file Copy-Item $HotFixPath $RemoteHotFixPath # Launch remote install & C:\Windows\PsExec -s \\$Server wusa C:\Windows\Temp\$HotFix /quiet /norestart # Clear session $RemoteHotFixPath = "" $HotFix = "" Write-Host "`n`n" if ($LastExitCode -eq 3010) { $Reboot = $true } } if($Reboot) # write message { Write-Host "$Server needs a restart." } }
Notes
https://www.catalog.update.microsoft.com/Search.aspx?q=KB4499175
tags: MrNetTek