Category filter

Script to change date format on Windows

On Windows devices, there are several methods to customize the date format, including running a PowerShell script on the device. With Hexnode’s Execute Custom Script action, you can remotely push a custom script to change the date format on your Windows endpoints.

Disclaimer:

The Sample Scripts provided below are adapted from third-party Open-Source sites.

PowerShell script to set a date format

Executing the above script will set the date format on the device to MM/dd/yyyy.

There are several options to choose from when deciding on a date format. The example script provided above sets the date on the device in the Short date format. If you wish to set a Long date format, replace the ‘sShortDate’ key with ‘sLongDate’ in the script and provide a suitable value for the $dateFormat variable.

To specify a date format, you must enter the codes representing each part of the date and time in the $dateFormat variable. Refer Microsoft’s documentation to get the format codes for the different date formats.

Examples for date formats:

Format Date
D/M/yy (Short date) 5/7/22
dddd, MMMM d, yyyy (Long date) Tuesday, July 5, 2022
Notes:

  • The specified date format is applied only to the user accounts logged in while executing the script.
  • 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