Welcome to the ConnectWise Control Remote Powershell PSWindowsUpdate. A great way to apply OS updates when MSP agents control build and feature updates.

PowerShell Commands

The commands are PowerShell (#!ps) commands. There are a couple attributes that affect how the commands respond.

#MaxLength - The max length of output characters. Some may need to be larger due to amount of output data.
#TimeOut - The period of time the command can run and will be terminated after the max has been hit. Most commands are quick to respond.

Let's set the execution policy.

Check Execution Policy

#!ps
#maxlength=50000
#timeout=9000000
Get-ExecutionPolicy
 

Set Execution Policy to Unrestricted

#!ps
#maxlength=50000
#timeout=9000000
Set-ExecutionPolicy Unrestricted
 

Install NuGet

#!ps
#maxlength=50000
#timeout=9000000
Install-PackageProvider -Name NuGet -RequiredVersion 2.8.5.201 -Force
 
The install of the module may fail so we need NuGet

Import NuGet

#!ps
#maxlength=50000
#timeout=9000000
Import-PackageProvider -Name NuGet -RequiredVersion 2.8.5.201
 

Install PSWindowsUpdate

#!ps
#maxlength=50000
#timeout=9000000
Install-Module PSWindowsUpdate -Force
 

Get OS Updates

#!ps
#maxlength=50000
#timeout=9000000
Get-WindowsUpdate
 
To remove certain products or updates add the following.
Category (-NotCategory);
Title (-NotCategory);
Update number (-NotKBArticleID).
 
EX: Get-WindowsUpdate -NotCategory "Drivers"
 

Get OS Updates

#!ps
#maxlength=50000
#timeout=9000000
Install-WindowsUpdate -AcceptAll -MicrosoftUpdate -ScheduleReboot 20:00
 
AutoReboot: automatically reboots system if required
IgnoreReboot: suppresses automatic restarts
ScheduleReboot: specifies the date when the system will be rebooted.
 
-ScheduleReboot and -AutoReboot might have issues with feature updates. -IgnoreReboot will help install these updates.

Conclusion

There you go! There are other OS update options that can be set but these are the remote commands that help me with my day to day MSP life.