question

vijayakumarD-1665 avatar image
0 Votes"
vijayakumarD-1665 asked vijayakumarD-1665 answered

Need to install microsoft update pacthes multiple remote servers

Hi All,

I have once script to install patch on remote server that i try files copied on destation path but not able to install the patch on server. But i want to install few patches multiple remote server i have 2012 server, 2016, 2019 some server have 3 or 4 patches need to install some server have single patch need to install how can i install that server operating system wise or patch wise please guide me powershell script experts.

I want output servername patch KBArticel installation status successfull or failed in csv file.


$servers = Get-Content -Path "C:\Temp\InstallPatch\Servers.txt"
$source = "\\server\d$\patch\dec2021\2012 Server Patch"
$dest = "c$\Temp\
$testpath = "\\server\d$\patch\dec2021\2012 Server Patch\Windows8.1-kb5008263-x64_6d9eb2beed6c47dcc3957105718fc061b3b80.msu"
foreach ($server in $server) {
if (Test-Connection -Computername $servers -quiet) {
Copy-Item $Source -Destination \\$Server\$dest -Recurse -Force
if (Test-Path -Path$testPath) {
Invoke-Command -ComputerName $Server -ScriptBlock {Powershell.exe C:\Temp\Install\Windows8.1-kb5008263-x64_6d9eb2beed6c47dcc3957105718fc061b3b80.msu /sAll /msu /norestart AllUSERS=1 EULA_ACCEPT=YES
}
Write-Host "Installation Successfull on $Server" -ForegroundColor Green
}
} else {
Write-Host "$server is not online, Unable to install Patch, Patch Failed" -ForegroundColor Red
}
}
$Results | Out-File "C:\Temp\InstallPatch\PatchStatus.csv"

windows-serverwindows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

Try a web search for powershell install msu remotely

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

vijayakumarD-1665 avatar image
0 Votes"
vijayakumarD-1665 answered

Hi

I tried with this below mention script files copied in script mention destination server location files available, But unable to install the windows update patch i provide the details with error and i have few doubts if possible try to give some solutions that i mention in after script.

$Servers = Get-Content -Path "C:\Temp\Patch\serverlist.txt"
$Source = "\\Server\D\Patching\feb22\win2012\"
$Dest = "C$\Temp\Patch\"
$Testpath = "\\Server\D\Patching\feb22\win2012\"
foreach ($Server in $servers) {
if (test-Connection -ComputerName $Servers) {
Copy-Item $Source -Destination \\$server\$dest -Rescurse -Force
if (Test-Path -Path $testpath) {
Write-Host "Patches Installing on $server"
Invoke-Command -ComputerName $server -ScriptBlock {(&cmd.exe /c or Powershell.exe wusa.exe /I "C:\Temp\Patch\Windows8.l-kb5008603-x64_58f1b60cb6250c4fb1e2d4c86o16eeef71ce6d1e.msu",
"windows8.1-kb5010215-x64_Oeclcede5ece93cee398a2366c6a6489627030.msu" /Quiet /norestart)}
Write-Host "Patch Installation Completed Successfully on $server" -ForegroundColor Green
}
} else {
Write-Host "Patch Installation Failed, $Server not reachable or not online" -ForegroundColor Red
}
}

  1. While i try to install windows update patch got failed facing error (I tried both &cmd.exe /c and powershell.exe) i checked in event viwer below error shown, but mentioned path kb article files availble in location

Windows update could not be installed of error 2147942402 "The System cannot find the file specified."(Command line ""C:\Windows\System32\wusa.exe" /I "C:\Temp\Patch\Windows8.l-kb5008603-x64_58f1b60cb6250c4fb1e2d4c86o16eeef71ce6d1e.msu",
"windows8.1-kb5010215-x64_Oeclcede5ece93cee398a2366c6a6489627030.msu" /Quiet /norestart)}

  1. I have Multiple OS 2012,2016,2019 and more KB Articles have in common path that all how can i install thorugh scripts (.msu,.msi,.msp,.exe) (.msu and .msi,.msp and .exe which one required to install patch like wusa.exe or msiexec.exe)

  2. Common path i have more files but i need to install few updates only like i have 7 or 8 patches,But i want to install 3 patches only that how can i install.

  3. I required out put details in csv or html file which patch got installed and which patch got not installed or failed on server wise with kb article details.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.