1
0

update.ps1 655 B

12345678910111213141516
  1. Set-ExecutionPolicy RemoteSigned -Scope Process -Force
  2. if (-not (Get-Module -ListAvailable -Name PSWindowsUpdate)) {
  3. Install-Module -Name PSWindowsUpdate -Force -Confirm:$false
  4. }
  5. Import-Module PSWindowsUpdate
  6. Write-Host "- Check updates"
  7. $updates = Get-WindowsUpdate
  8. if ($updates.Count -eq 0) {
  9. Write-Host "- Not find any new updates" -ForegroundColor Green
  10. return
  11. }
  12. Write-Host "- Available updates:" -ForegroundColor Yellow
  13. $updates | Select Title, KB, Size
  14. Write-Host "- Download and install updates"
  15. Install-WindowsUpdate -AcceptAll -AutoReboot -IgnoreReboot
  16. Write-Host "- Finished, need reboot device" -ForegroundColor Green