How To Install Msu File Remotely With Powershell
Windows Update Standalone Installer
The patch installation is done via wusa.exe.
The following print screen shows the parameters of the Windows Update Standalone Installer.
local installation
As far as I know, the patch cannot exist installed with native powershell, ways we accept to address the wusa.exe in powershell. Of course Powershell is a nice manner to automate the whole process.
In the post-obit instance, the patch is copied from a UNC share and installed locally.
$ patchname = "kb13245.msu" $ patchsource = "\\some\unc\path\kb13245.msu" Copy - Particular $ patchsource - Destination "$env:SystemDrive\Temp" - Force wusa . exe "$env:SystemDrive\Temp\$patchname" / quiet |
remote installation
I was not able to run wusa.exe remotely, any tests with workflows, Remotepowershell (Invoke-Command CMDLeet) failed. Even triggering a localy copied batch file caused problems. The wusa.exe procedure was executed with the correct parameters but aborted afterwards a few seconds.
Even with an Invoke-Command and the parameter -Wait it didn't work.
Probably information technology'south considering yous intervene in the system and perform an unauthorized action.
With the PSExec.exe information technology is possible to start the process remotely.
The principle is very simple, you have to copy the patch to the appropriate target computer. Then PSExec starts a remote process on the target calculator and executes the wusa.exe with the corresponding parameters. The wusae.exe must point to the path where the patch was copied.
#16.05.2019 by JKU $ Hotfix = 'kb-12345.msu' $ HostName = 'F.Q.D.North' $ DestinationPath = "\ \ $ Hostname \ c $ \ Temp \" Copy - Item C : \ temp \ $ Hotfix - Destination $ DestinationPath #Starting time Process with PSExec.exe & amp ; C : \ Temp \ PsExec . exe - accepteula - s \ \ $ HostName wusa C : \ Temp \ $ Hotfix / quiet / norestart |
And and so yous can distribute a patch for multiple computers with a simple iteration.
total remote automation
There are of course several ready-made scripts to install multiple patches on multiple computers. The script which I utilise in the company environment, I have inserted below. The code does not come from me, but from the post-obit forum mail: https://customs.spiceworks.com/topic/2054098-silently-install-patches-remotely-and-reboot?page=1#entry-7246666
one ii 3 four 5 6 7 8 ix 10 xi 12 13 14 fifteen 16 17 18 nineteen 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #by https://customs.spiceworks.com/topic/2054098-silently-install-patches-remotely-and-reboot?page=i#entry-7246666 $ RootHotfixPath = 'Patches\' $Hotfixes = @(' KB3125574_x64 . msu ') $Servers = Become-Content ' MachineList . txt' foreach ( $ Server in $ Servers ) { Write - Host "Processing $Server..." $ needsReboot = $ False $ remotePath = "\\$Server\c$\Temp\Patches\" if( ! (Test-Connection $Server -Count one -Tranquillity)) { Write-Alert " $ Server is non accessible " go along } if(!(Test-Path $remotePath)) { New-Item -ItemType Directory -Force -Path $remotePath | Out-Aught } foreach ($Hotfix in $Hotfixes) { Write-Host " ` thotfix : $ Hotfix " $HotfixPath = " $ RootHotfixPath $ Hotfix " Copy-Item $Hotfixpath $remotePath # Run command as Arrangement via PsExec (-s switch) & C:\Windows\PsExec -due south \\$Server wusa C:\Temp\Patches\$Hotfix /quiet /norestart write-host " & amp ; C : \ Windows \ PsExec - due south \ \ $ Server wusa C : \ Temp \ Patches \ $ Hotfix / repose / norestart " if ($LastExitCode -eq 3010) { $needsReboot = $truthful } } # Delete local re-create of update packages Remove-Particular $remotePath -Force -Recurse if($needsReboot) { Write-Host " Restarting $ Server . . ." Restart - Computer - ComputerName $ Server - Forcefulness - Confirm } } |
Source: https://techblog.jere.ch/2019/05/15/microsoft-local-remote-patchinstallation-with-powershell/
Posted by: gordonnothad86.blogspot.com
0 Response to "How To Install Msu File Remotely With Powershell"
Post a Comment