Category filter

PowerShell Script to Automate Windows OS Updates remotely via Hexnode UEM

Maintaining a unified OS version across an enterprise fleet is a critical component of security compliance. This guide demonstrates how to automate Windows OS updates remotely using Hexnode UEM’s Execute Custom Script feature, providing administrators with a robust mechanism to trigger the native Windows Update engine.
This orchestration script automatically verifies required system services and initiates an on-demand scan, downloads, and installs the latest compatible updates. This ensures a transparent and granular way to manage critical security patches and version jumps across the entire Windows inventory.

System Requirements

  1. Hardware & Operating System

    • Operating System: Windows 10 (Version 1607 or later), Windows 11.
    • Architecture: x86, x64, or ARM64 (the script dynamically identifies these during execution).
    • Disk Space: 6GB (Minimum), 10GB (Recommended)
  2. Network & Connectivity

    • Stable Internet: A stable internet connection to download required files.
    • BITS Service: The Background Intelligent Transfer Service (BITS) must be active for Windows Update orchestration to succeed.


      If BITS is disabled on your target devices, remotely execute the following script via the Hexnode portal before initiating the update:

Executing custom script via Hexnode UEM- Quick steps

  1. Navigate to the Manage tab in your Hexnode UEM console and select your Windows device.
  2. From Actions, select Execute Custom Script from Deployments.
    The Execute Custom Script action is found under the “deployments” subsection of the Remote actions for the Windows device.
  3. Upload the .ps1 PowerShell script and click Execute.
Note:


The sample scripts provided are adapted from open-source repositories. Administrators must review and execute them on a test machine before initiating a bulk deployment across the production environment.

PowerShell script to install latest Windows OS

This PowerShell script enables administrators to remotely scan, download, and install the latest version of Windows OS updates across a device fleet via Hexnode UEM.

Post-Deployment Verification

Once the script is executed, the real-time output and execution logs are captured and displayed within the Action History tab of the Hexnode UEM console. This provides administrators with immediate visibility into the update lifecycle. You can quickly confirm whether the device is already compliant, if a download has been initiated, or if a system reboot is pending.

To review the execution logs, follow these steps within your Hexnode UEM portal:

  • Navigate to the Action History tab under the specific device.
  • Locate the entry for your PowerShell script (e.g., “Update OS”) in the Subject column.
  • Click the Show Output button located next to the status field.

Hexnode UEM portal displaying the Windows OS update log and successful execution of the orchestration script.

Key Benefits and Use Cases

  • Rapid Vulnerability Mitigation: By triggering the Windows Update engine remotely, an organization can achieve near-instant compliance across the fleet, bypassing the standard 24-hour delay often associated with native automatic updates.
  • Automated Service Remediation: The script ensures the Background Intelligent Transfer Service (BITS), and Windows Update services are active, automatically repairing “broken” update agents on remote endpoints without manual IT intervention.
  • Zero-Touch Deployment: Administrators can force critical OS patches on home-based or remote laptops via Hexnode UEM, ensuring systems stay updated even if users ignore “Update and Restart” notifications.
  • Verified Compliance Reporting: Detailed execution logs are returned to the Hexnode UEM console, providing an audit trail that confirms whether the device has successfully initialized the update process or requires a reboot.

Implementing this orchestration script ensures that Windows devices remain secure and compliant without manual intervention. By automating service checks and forcing the update engine to run via Hexnode UEM, administrators can maintain elevated security standards across hybrid environments. This streamlined approach minimizes downtime, optimizes bandwidth usage, and provides an audit trail, ensuring every endpoint in your organization stays current with the latest Microsoft security patches.

Sample Script Repository