I am trying to update windows servers remotely with the PS Module PSWindowsUpdate via this scriptblock:
#Will Update Windows, automatically reboot and out the log in the specified directory. This will be done to all listed Servers
ForEach ($Index in $Servers)
{
$Scriptblock = {
Invoke-WUJob -Comp $Index -RunNow -Confirm:$false -Verbose -Script {
Install-WindowsUpdate -MicrosoftUpdate -NotCategory "SilverLight" -NotTitle "Preview" -AcceptAll -AutoReboot | Out-File C:\PSWindowsUpdate.log
}
}
Invoke-Command -Comp $Index -ScriptBlock $Scriptblock
}
However the task gets created on the Remote PC I am testing this on with ID 4702 "Other Object Access Events". But it never really seems to do anything even though the scheduled task has all the information in it.
I have installed the module on the host pc and remote server, NuGet is installed and TLS 1.2 is enabled as well.
The PSWindowsUpdate.log file is created in (C:) but has nothing in it. The rest of the script just stops some services and boots them up after the supposed update has been done, which also seems to work.
What I also tried was to remotely activate another update script on the server, that is supposed to download the update and install it but I keep getting Access is denied
messages, which was expected.
Any other solutions you might have to update multiple windows servers at once or how to get Invoke-WUJob to work would be appreciated!