【问题标题】:Pushing Windows Updates Via Powershell通过 Powershell 推送 Windows 更新
【发布时间】:2017-08-15 11:42:10
【问题描述】:

由于需要修补的计算机数量,我正在尝试通过 powershell 安装某些 Windows 更新。

我使用以下语法;

enter-pssession PCname-PC

连接会话后,我使用以下内容;

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

手头的问题是什么都没有发生,而且我每次都收到拒绝访问。 Powershell 以管理员身份运行,计算机的本地用户是管理员。我尝试运行允许会话以域管理员身份连接的脚本,结果相同。

在这件事上的任何帮助将不胜感激。谢谢

【问题讨论】:

  • 或者你可以试试这个:$pc="PC" $comm = "cmd /c wusa.exe c:\temp\update.msu /quiet /norestart /log:C:\wusa.log" ([wmiclass]"\\$pc\root\cimv2:Win32_Process").create($comm)
  • 或者你可以尝试使用凭证参数:Enter-PSSession -ComputerName PC1 -Credential contoso\administrator
  • 某些版本的 Windows 会阻止您写入 C:\ 驱动器的根目录。尝试将 /log 更改为另一个目录。
  • 谢谢大家,我会尝试你的建议并更新

标签: powershell networking powershell-remoting winrm


【解决方案1】:

remote use of the Windows Update Agent API is restricted。有几种解决方法围绕在本地启动该过程。正如 Vitaly 在 cmets 中指出的那样,通过 WMI 启动进程或创建计划任务。

【讨论】:

    【解决方案2】:

    此解决方案最终会将更新复制到每台 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)

    【讨论】:

    • 问题是 wusa.exe 不能在远程会话中运行。拒绝访问的不是文件,而是 Windows Update API....
    猜你喜欢
    • 1970-01-01
    • 2021-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-09
    • 1970-01-01
    • 2021-09-16
    相关资源
    最近更新 更多