1
0

update.ps1 715 B

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