Good day.
I want to remotely run a Windows update from 1809 to 1903.
If I enter commands one by one, the computer will reboot and install the update.
Here are the commands that I enter
Enter-PSSession ComputerName-001 -Verbose
Start-Process -FilePath 'C:\$WINDOWS.~BT\Sources\SetupHost.exe' -WorkingDirectory 'C:\$WINDOWS.~BT\Sources' -ArgumentList '/finalize /update'
Get-PSSession | Remove-PSSession
But when I run these commands as a script, I get an error
The command cannot be executed because the "WorkingDirectory" parameter has an invalid value or cannot be used with this command. Enter valid data and try again.
InvalidOperation: (:) [Start-Process], DirectoryNotFoundException
DirectoryNotFoundException,Microsoft.PowerShell.Commands.StartProcessCommand
I can not overcome this problem
I tried Invoke-Command but the process does not start.
Tell me how to make it work in the script.