Powershell Remote:Microsoft.Update.Session,拒绝访问:0x80070005

时间:2011-08-16 13:30:18

标签: com powershell

我编写了一个脚本,使用Microsoft.Update.Session COM对象在计算机上搜索/下载/安装Windows更新。在本地运行时它可以正常工作,但是当通过远程会话或通过Invoke-Command运行时,我在Microsoft.Update.Session.CreateUpdateDownloader()上收到拒绝访问(0x80070005)错误

如果我尝试直接创建Downloader对象,代码重现问题,我会收到同样的错误:

$oUpdateDownloader = new-object -com "Microsoft.Update.Downloader" 

我是远程计算机的管理员,并且将凭据(显式为自己或任何其他管理员帐户)传递给计算机似乎没有任何改变。

我已经多次看到此错误,但似乎没有任何关于解决问题的信息......

有什么想法吗?

5 个答案:

答案 0 :(得分:3)

这是一个已知问题。看来实际的COM对象本身存在一个错误,因为使用VBScript,PowerShell甚至C#时会出现此问题。有一篇很好的文章讨论了如何使用PowerShell管理Windows Update here

解决方法是在计算机上设置计划任务,您可以根据需要调用该任务。

答案 1 :(得分:2)

使用PsExec(http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx)通过脚本文件远程执行PowerShell:

psexec -s \\remote-server-name C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe \\server\script.ps1

我使用了http://www.ehow.com/how_8724332_use-powershell-run-windows-updates.html详细说明的脚本,我可以使用psexec远程执行它来下载和安装更新。

答案 2 :(得分:1)

Windows更新代码无法从远程计算机调用。网上有一些解决方法,包括使用psexec和脚本(powershell或vbscript)。

我自己使用WUInstallBoeProx记录了一些替代方案,并启动了PoshPAIG项目。我在使用之前移动了工作,所以不知道它是否有效。

答案 3 :(得分:0)

另一种解决方案是使用PowerShell更改Windows注册表设置,并可选择重新启动wuauserv以使更改生效。

例如,在Windows Server 2008R2中,可以在以下位置找到AutoUpdate设置:

HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update

答案 4 :(得分:0)

在远程PowerShell会话中时,此远程计算机上的登录会话被标记为“网络”登录(登录类型:3)。 出于某种晦涩的原因(安全性?出售SCCM?),Windows Update Agent COM APIs are restricted的一部分只能由本地登录的管理员使用。

已建议使用PsExec和计划任务作为解决方法。

IMO,最无缝(也是最安全的 )解决方案是促进PowerShell Session Configurations的RunAs风格的“ 本地虚拟帐户”功能/ JEA。 通常,JEA通常用于"restrict"用户在PowerShell上可以在远程计算机上执行的操作,但是我们在这里(ab-)使用它来获得完全访问权限,就像我们是本地登录的管理员一样。

(1。)在 location / { # proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; add_header X-Upstream $upstream_addr always; proxy_pass_header Server; proxy_redirect off; proxy_set_header X-Scheme $scheme; proxy_pass http://127.0.0.1:10000; } (远程服务器)上创建新的不受限制(且持久!)的会话配置:

ComputerB

(2。)从New-PSSessionConfigurationFile -RunAsVirtualAccount -Path .\VirtualAccount.pssc # Note this will restart the WinRM service: Register-PSSessionConfiguration -Name 'VirtualAccount' [-ShowSecurityDescriptorUI] -Path .\VirtualAccount.pssc -Force # Check the Permission property: Get-PSSessionConfiguration -Name 'VirtualAccount' # Those users will have full unrestricted access to the system! (本地客户端)连接到ComputerB上的不受限制的会话配置:

ComputerA
相关问题