I can't get the last invoke command in this script to run to install windows updates on remote machine. I receive "access is denied"

0

Doesn't run the last invoke command. This is the error message I receive:

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

Is there something I can do/modify to get the last command to run on the remote machine without running into a permission issue?

$session = New-PSSession -ComputerName 10.10.10.10 -Credential $cred -Verbose
Start-Sleep -s 3
Invoke-Command -Session $session {Set-Service wuauserv -StartupType Manual -Verbose}
Start-Sleep -s 3
Invoke-Command -Session $session {Start-Service wuauserv -Verbose}
Start-Sleep -s 5
Invoke-Command -Session $session {Get-Service wuauserv | Select-Object -Property Name, StartType, Status -Verbose}
Start-Sleep -s 5
Invoke-Command -Session $session {Get-WindowsUpdate -AcceptAll -IgnoreReboot -Install -Verbose | Out-File C:\Windows\PSWindowsUpdate.log}
powershell
powershell-5.0
asked on Stack Overflow Mar 16, 2020 by jeff4765 • edited Mar 17, 2020 by jeff4765

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0