Install MS Hotfix (not regular update) script

Welcome Forums General PowerShell Q&A Install MS Hotfix (not regular update) script

This topic contains 1 reply, has 2 voices, and was last updated by

4 years, 9 months ago.

  • Author
  • #12514

    Points: 0
    Rank: Member


    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
    } else {
    Write-Host "Folder C:\Temp does not exist on the target server"

  • #12527

    Points: 0
    Rank: Member

    What error messages are you getting?

The topic ‘Install MS Hotfix (not regular update) script’ is closed to new replies.