Category filter
Script to download and install OS updates
It is imperative to download and install OS updates released by Microsoft as these updates might fix bugs and security flaws in your system. Using Hexnode, you can deploy scripts and effortlessly update the Windows devices to the latest version.
Batch script
1 2 3 4 |
usoclient ScanInstallWait usoclient StartInstall timeout /t time _to_wait_in seconds usoclient RestartDevice |
The usoclient.exe commands do not provide any feedback on the terminal when executed manually or on the Hexnode portal if the script is deployed through the portal. The only way to ensure that the commands are working is to check if the updates are being downloaded under Settings > Update & Security > Windows Update on the devices.
PowerShell script
The device must have the PSWindowsUpdate
module to initiate the OS update. The script below silently installs the PSWindowsUpdate
module and then downloads the OS updates.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
try { if(Get-PackageProvider | Where-Object {$_.Name -eq "Nuget"}) { "Nuget Module already exists" } else { "Installing nuget module" Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force } if(Get-Module -ListAvailable | where-object {$_.Name -eq "PSWindowsUpdate"}) { "PSWindowsUpdate module already exists" } else { "Installing PSWindowsUpdate Module" install-Module PSWindowsUpdate -Force } Import-Module -Name PSWindowsUpdate "Starting updation -->" + (Get-Date -Format "dddd MM/dd/yyyy HH:mm") install-WindowsUpdate -AcceptAll -ForceDownload -ForceInstall -IgnoreReboot "Updation completed -->"+ (Get-Date -Format "dddd MM/dd/yyyy HH:mm") } catch { Write-Output $_.Exception.Message } |