Powershell Remote: Microsoft.Update.Session, Access Denied: 0x80070005

前端 未结 5 2082
面向向阳花
面向向阳花 2021-01-03 00:14

I\'ve written a script to search/download/install Windows Updates on a machine using the Microsoft.Update.Session COM Object. When run locally it works just fine, however wh

相关标签:
5条回答
  • 2021-01-03 00:56

    Use PsExec (http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx) to remotely execute PowerShell with a script file:

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

    I used the script detailed at http://www.ehow.com/how_8724332_use-powershell-run-windows-updates.html, and I can remotely execute it using psexec to download and install updates.

    0 讨论(0)
  • This is a known issue. It appears that there is a bug with the actual COM object itself, as this issue occurs when using VBScript, PowerShell, and even C#. There is a good article that discusses managing Windows Update with PowerShell that can be found here.

    The workaround is to set up a scheduled task on the computer and you can invoke that task however you see fit.

    0 讨论(0)
  • 2021-01-03 01:03

    When you are in a remote PowerShell session your logon session on this remote computer is flagged as a "network" logon (Logon Type: 3). For some obscure (security? sell SCCM?) reason, part of the Windows Update Agent COM APIs are restricted to only be usable by locally logged on Administrators.

    Using PsExec and Scheduled Tasks have been suggested as workarounds.

    IMO, the most seamless (and still secureable) solution is to facilitate the RunAs-style "Local Virtual Account" feature of PowerShell Session Configurations / JEA. Usually, JEA is used to "restrict" what a user can do on a remote computer PowerShell-wise, but we are (ab-)using it here to gain full access as if we were a locally logged on Administrator.

    (1.) Create a new unrestricted (and persistent!) session configuration on ComputerB (remote server):

    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!
    

    (2.) From ComputerA (local client) connect to our unrestricted session configuration on ComputerB:

    New-PSSession -ComputerName 'ComputerB' -ConfigurationName 'VirtualAccount' | Enter-PSSession
    [ComputerB]: new-object -com "Microsoft.Update.Downloader" # Yay!
    
    0 讨论(0)
  • 2021-01-03 01:06

    The other solution is to change Windows registry setting using PowerShell and optionally restart wuauserv for the changes to take effect.

    For example in Windows Server 2008R2 AutoUpdate settings can be found at:

    HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update
    
    0 讨论(0)
  • 2021-01-03 01:14

    the windows update code isn't callable form a remote machine. there are a few workarounds out on the web, including using psexec and a script (powershell or vbscript).

    I used WUInstall myself and BoeProx has documented a few alternatives and has started a project PoshPAIG. I moved jobs before using this so don't know if it works.

    0 讨论(0)
提交回复
热议问题