'Trying to run Get-WindowsUpdate on a remote computer but get: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

I've got a powershell script to remote into other computers to get and install windows updates.

I'm logged into the admin account on my local machine. The script starts a powershell remote session into another computer which works fine.

Then once in the remote session the script should run:

Get-WindowsUpdate -AcceptAll -Install -AutoReboot

but i get this error:

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
    + CategoryInfo          : NotSpecified: (:) [Get-WindowsUpdate], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,PSWindowsUpdate.GetWindowsUpdate

I tried suggested solutions of changing the WMI permissions and I allowed this in the firewall settings but it still did not work.



Solution 1:[1]

I have successfully scripted it by using:

?

Get-WindowsUpdate -verbose -computer $RemoteServer -AcceptAll -Install -AutoReboot

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 another victim of the mouse