Install-Module -Name PSWindowsUpdate -Force Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force Import-Module PSWindowsUpdate Get-WindowsUpdate -AcceptAll -Install -IgnoreReboot Set-ExecutionPolicy Restricted -Force (New-Object -ComObject "Microsoft.Update.SystemInfo").RebootRequired # Check if PSWindowsUpdate module is installed, if not install it if (-not (Get-Module -ListAvailable -Name PSWindowsUpdate)) { Install-Module -Name PSWindowsUpdate -Force } # Import the PSWindowsUpdate module Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force Import-Module PSWindowsUpdate # Get a list of available updates $Updates = Get-WindowsUpdate -AcceptAll -IgnoreReboot # Install the available updates Install-WindowsUpdate -Updates $Updates -AcceptAll -IgnoreReboot Set-ExecutionPolicy Restricted -Force