安装离线Windows更新(.msu)到远程服务器



我正试图得到一个脚本一起远程安装一些windows更新在一些远程服务器连接在一个离线域。

我尝试过常规的PS Remoting,经过一些研究,我认为我想做的是微软不支持的。当检查我的事件日志时,我发现了一堆这样的错误。

编辑

我想补充的是,我已经尝试从我的本地计算机运行.Install2012R2.ps1脚本,修改为在其中包含Invoke-Command,并让它运行原始Install2012R2.ps1的更新部分,我会得到相同的错误。

我希望通过在每个服务器上放置脚本,它会更喜欢。

结束编辑

Windows update  could not be installed because of error 2147942405 "Access is denied."
(Command line: ""C:WindowsSystem32wusa.exe" "C:Updateswindows8.1-kb4556853-x64.msu" /quiet /norestart")

我已经尝试运行Invoke-Command作为认证到服务器上的管理员帐户,但我一直没有运气,正在寻找一些建议,如果有人可能已经尝试/做过这个。

$Servers = @("V101-Test1","V101-Test2")
$Username = 'admin'
$Password = 'Password'#not actual password
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
Get-PSSession | Remove-PSSession
New-PSSession -ComputerName $Servers
foreach($Server in $Servers){
Get-ChildItem -Path C:SourceTemp -Recurse | Copy-Item -Destination "\$Serverc$Updates" -Force
}
Invoke-Command $Servers -Credential $Cred -ScriptBlock{
& "C:UpdatesInstall2012R2.ps1"
}

编辑2

下面是Install2012R2的实际安装代码。ps1脚本

$updatedir= "./"
$files = Get-ChildItem $updatedir -Recurse

$msus = $files | ? {$_.extension -eq ".msu"}
$exes = $files | ? {$_.extension -eq ".exe"}
foreach ($file in $msus){
$KBCtr++
$fullname = $file.fullname

# Need to wrap in quotes as folder path may contain space   
$fullname = "`"" + $fullname + "`""
$KBN = $fullname.split('-')[1]
# Need to wrap in quotes as folder path may contain space   
$fullname = "`"" + $fullname + "`""
# Specify the command line parameters for wusa.exe
$parameters = $fullname + " /quiet /norestart"
# Start services and pass in the parameters
$install = [System.Diagnostics.Process]::Start( "wusa",$parameters )
$install.WaitForExit()
}

我不知道为什么wusa.exe在这里失败与拒绝访问,但这里是一个powershell本地的方法,你可以尝试。如果没有其他问题,它应该通过捕获的错误信息为您提供关于潜在问题的更清晰的指示:

Add-WindowsPackage -Path C:UpdatesOurHeroicUpdate.msu -Online -PreventPending -NoRestart
  • -Pathmsu文件的路径
  • -Online告诉Add-WindowsPackage修改当前"挂载的图像";Windows的(运行版本)(与离线磁盘映像相反,您也可以将其应用于)
  • -PreventPending防止安装msu如果已经有一个悬而未决的变化,如需要重新启动更新。

Add-WindowsPackage是Windows PowerShell下可用的DISM模块的一部分,其功能相当于dism /packagepath:"cabfile",尽管它可以接受msu,而dism.exe只允许cab

最新更新