2017-08-15 104 views
1

我想通过PowerShell安装某些Windows更新,因为我需要修补的计算机数量。通过Powershell推送Windows更新

我使用以下语法;

enter-pssession PCname-PC 

一旦会话连接,我使用以下;

wusa.exe c:\temp\update.msu /quiet /norestart /log:C:\wusa.log 

手头的问题是没有任何反应,我每次都收到拒绝访问。 Powershell作为管理员运行,本地计算机用户是管理员。我曾尝试运行一个脚本,允许会话以域管理员身份进行连接,并获得相同的结果。

任何帮助在这个问题将不胜感激。谢谢

+0

或者你可以试试这个:$ PC =“PC “[wmiclass]”\\ $ pc \ root \ cimv2“$ comm =”cmd/c wusa.exe c:\ temp \ update.msu/quiet/norestart /log:C:\wusa.log“ :Win32_Process“)。create($ comm)' – Vitaly

+0

或者你可以尝试使用credentional参数:'Enter-PSSession -ComputerName PC1 -Credential contoso \ administrator' – Vitaly

+0

S Windows版本阻止您写入C:\驱动器的根目录。尝试更改/登录到另一个目录。 –

回答

0

该解决方案最终会复制更新每台PC:

$PCs = @() 
$Cred = Get-Credential 

ForEach ($PC in $PCs) 
{ 
    $Session = New-PSSession -ComputerName $PC -Credential $Cred 
    Copy-Item -Path 'C:\Temp\Update.msu' -Destination 'C:\Temp\Update.msu' -ToSession $Session -Force 
    Enter-PSSession $Session 
    & wusa C:\Temp\Update.msu /quiet /norestart /log:C:\Temp\wusa.evtx 
    Exit-PSSession 
    Remove-PSSession $Session 
} 

最后一个音符:在事件查看器格式WUSA日志(.evtx

+0

问题是wusa.exe不能在远程会话中运行。拒绝访问不是文件,而是Windows Update API .... – BenH