Hi,
The comparison operator in PowerShell is "-lt", not "<" and you should specify the if block using the curly braces.
if((Get-CimInstance Win32_OperatingSystem).BuildNumber -le 19042)
{
Set-ExecutionPolicy unrestricted
Install-Module PSWindowsUpdate
Import-Module PSWindowsUpdate
Get-WindowsUpdate -KBArticleID KBXXXXXX -Install -AcceptAll -AutoReboot
}
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.