And everything I put it in gives the error:
Invoke-WUJob : Cannot convert ‘System.String’ to the type ‘System.Management.Automation.SwitchParameter’ required by parameter ‘RunNow’.
If you look at this example, Invoke-WUJob has a parameter for -RunNow which is the prompt you are getting for the alias command Invoke-WUInstall. Look at the steps in this guide to see if it works as expected:
Now I am getting a “connecting to remote server failed. WinRM cannot complete the operation.” Is it accessible over the network, firewall exception for WinRM… etc. Firewall is off, it is pingable, and a firewall exception is on. WinRM Service is running too.
Looks like you need to enable PSRemoting on the remote systems. Google that. Also, on the system running the script, make sure you have Trusted Hosts enabled for the WinRM Client. Google that as well.
I have done both already.
Enable-PSRemoting
winrm set winrm/config/client ‘@{TrustedHosts=“TRJWIN10-9”}’
As well as updating execution policy,
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted -Force
I ended up doing all commands I just replied with on remote computer, not it’s giving me "The network path was not found. (Exception From HRESULT: 0x60070035). I tried IP instead of TRJWIN10-9, still nothing. The machine is pingable. Would it matter if it’s a virtual machine?
Being a VM should not matter. I do all my testing on VM’s in my lab and for all intensive purposes, they act “virutally” the same as a physical box
PowerShell remote can be a finicky beast. Here are the general rules I use in troubleshooting PS remoting:
The system running the script must have Trusted Hosts enabled
The remote system must be accessible by hostname, IP addresses will NOT work
The remote system must respond to a ping
PowerShell Remoting must be enabled on the remote system
Access to C$ on the remote system - as in "dir \\hostname\c$"
Access to the Remote Registry on the remote system (remote registry service enabled)
Sorry for the late reply, got really busy with some other stuff. I took a look at this again, and
1.Trusted hosts has been set
2.Remote system is accessible through hostname(file explorer, pings, and the dir \hostname\c$)
3.PSRemoting has been enabled.
I did not have Remote Registry enabled on the remote client, so I have just enabled that. I am now stuck at this error again:
Invoke-WUJob : Cannot convert ‘System.String’ to the type ‘System.Management.Automation.SwitchParameter’ required by parameter ‘RunNow’.
I have also tried Invoke-WUJob -ComputerName TRJWIN10-2 -Script {ipmo PSWindowsUpdate; Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot} -RunNow -Confirm:$false
But it says it cannot find the file specified, referring to -Script {ipmo PSWindowsUpdate;…
It looks like it does not like your -Confirm:$false. It wants a Switch Paramater which means the argument is valid as long as the argument is there, there are no settings for the argument and you are feeding it $False. Have you tried running without the -Confirm argument?