Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set-ExecutionPolicy Unrestricted -Force
- Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
- Install-Module PSWindowsUpdate -Force
- Import-Module PSWindowsUpdate -Force
- do {
- # Retrieve list of available updates
- "Checking for new updates..."
- $updates = Get-WUList -Verbose -NotTitle Silverlight
- # Count how many updates are available
- $updatenumber = ($updates.kb).count
- # If there are available updates proceed with installing the updates and then reboot
- if ($null -ne $updates) {
- Get-WindowsUpdate -AcceptAll -Install -AutoReboot -NotTitle Silverlight | Out-File $env:temp\PSWindowsUpdate.log
- # Show update status until the amount of installed updates equals the same as the amount of updates available
- Start-Sleep -Seconds 30
- do {
- $updatestatus = Get-Content $env:temp\PSWindowsUpdate.log
- "Currently processing the following update:"
- Get-Content $env:temp\PSWindowsUpdate.log | select-object -last 1
- Start-Sleep -Seconds 10
- $ErrorActionPreference = 'SilentlyContinue'
- $installednumber = ([regex]::Matches($updatestatus, "Installed" )).count
- $ErrorActionPreference = 'Continue'
- }
- until ( $installednumber -eq $updatenumber)
- }
- }
- until($null -eq $updates)
- # Update all Windows Store apps
- Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" | Invoke-CimMethod -MethodName UpdateScanMethod
- Write-Output "Windows is now up to date, restarting"
- shutdown /r /f
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement