Apply service packs (.msu file) update using powershell scripts on local server

不想你离开。 提交于 2019-12-06 12:11:30

You're copying the file(s) to a local folder (C:\temp), but run wusa on a remote host. That host may have the same local folder, but you didn't copy the update(s) to that folder. If you want to install the updates from a local folder on a remote host, you must copy them to that folder on the remote host:

Copy-Item $from "\\$hostname\$($to -replace ':','$')" -Recurse -Force

Edit: Since you want to install the updates on the host running the script your code should work in general, although I'd streamline it a little, e.g. like this:

$from = "sourceLocation\*.msu"
$to   = 'C:\temp'

Copy-Item $from $to -Recurse -Force

$updates = @(Get-ChildItem –Path $to -Filter '*.msu')
if ($updates.Count -ge 1) {
  $updates | % {
    Write-Host "Processing update $($_.Name)."
    & wusa $_.FullName /quiet /norestart
  }
} else {
  Write-Host 'No updates found.'
}

Is UAC enabled on the host? In that case you need to run the Script "as Administrator" when running it manually, or with the option "run with highest privileges" checked when running the script as a scheduled task.

The answer was simple. All i needed was a /install command parameter. So the line should be

 & wusa /install $to$msu  /quiet /norestart 

 OR

  & wusa $to$msu  /quiet /norestart 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!