Category filter

Script to Shut Down Windows devices

Shutting down a Windows device ensures energy efficiency, component longevity, and resolves persistent hardware issues. A shutdown guarantees a complete power cycle. The heat stress on internal components such as CPU, GPU, hard drives etc. due to long periods of idle or sleep mode is also minimized. Shutting down a device remotely can help administrators with troubleshooting and correcting boot-related conflicts as the device truly goes offline, before the next booting. Hexnode UEM allows admins to run custom scripts to shut down or schedule shutdown of Windows devices using Execute Custom Script action, remotely. In this article, both PowerShell and Batch scripts are provided to perform shutdown.

Supported Versions:


The scripts are supported for execution on the following Windows versions:

  • Windows 10 v1803+
  • Windows 10 v1703 to Windows 10 v1709 (if .NET Framework v4.7.1+ is installed on the device)
  • Windows 11 (Pro, Enterprise, Education)

Warning


The sample scripts provided below are adapted from third-party open-source sites.

Batch scripts

  1. Shutting down the device immediately

    Once the command is executed, the device shuts down after displaying a warning message.

  2. Scheduling the shutting down of the device

    By customizing the parameter /t, you can schedule shutdown to proceed after the specified number of seconds.Here, an example has been provided to shut down the device in 15 seconds.

  3. Schedule a shut down on Windows devices

    Powershell script

    The Stop-Computer cmdlet is used to shutdown the device. Replace computer_name with the name or IP address of the device that needs to be shutdown.-force compels the device to shut down without prompting confirmation.

    Notes:

    • It is recommended to manually validate the script execution on a system before executing the action in bulk.
    • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

Sample Script Repository