Import-Module PSWindowsUpdate echo Check for available updates and count them $updatesCount = (Get-WindowsUpdate -MicrosoftUpdate).Count echo Display the number of available updates Write-Output "There are $updatesCount updates available." echo Check for available updates, install them, and reboot if necessary Get-WindowsUpdate -MicrosoftUpdate -AcceptAll -Install -AutoReboot