Install MS Hotfix (not regular update) script

Hello,

I am trying to deploy a hotfix on multiple systems and it’s not a standard Windows Update. I’ve put together a script from pieces of others I found online and it works but not on Windows 2008R2 servers and I know it’s PSEXEC.

What I read on one forum page was that someone else ran into a similar issue and although their script did something a bit different, the script used psexec but they solved it by running it using an elevated command prompt with admin credentials.

I’m using powershell running it as administrator and I have domain admin access, but it’s still failing. Can anyone help me or provide a better option? (I’m using powershell 3 on my system and running this on 2003 and 2008 systems)

$Servers = Get-Content ‘\Fileserver\Hotfixes\ServerList.txt’ | foreach {“SERVER$_”})
$HotfixPath = '\Fileserver\Hotfixes\hotfix1.exe

foreach ($Server in $Servers){
if (Test-Path “\$Server\c$\Temp”){
Write-Host “Processing $Server…”
# Copy update package to local folder on server
Copy-Item $Hotfixpath “\$Server\c$\Temp”
# Run command as SYSTEM via PsExec (-s switch)
& c:\scripts\sysinternals\PsExec -s \$Server wusa C:\Temp\hotfix.exe /quiet /norestart
if ($LastExitCode -eq 3010) {
$ConfirmReboot = $False
} else {
$ConfirmReboot = $True
}
# Delete local copy of update package
Remove-Item “\$Server\c$\Temp\hotfix.exe”
Write-Host “Restarting $Server…”
Restart-Computer -ComputerName $Server -Force -Confirm:$ConfirmReboot
Write-Host
} else {
Write-Host “Folder C:\Temp does not exist on the target server”
}
}

What error messages are you getting?