Category filter

Script to create a new folder if it doesn’t exist on Windows

A system admin might need to create new folders on employee devices to keep things organized. Doing this manually on each device would be a hassle, especially if the company has numerous endpoints deployed across the globe. This doc assists you on how to remotely create a new folder on Windows devices if it doesn’t already exist by executing custom scripts via Hexnode UEM.

Note:


Supported Versions:

The scripts given below will be supported on the following versions:

  • Windows 10 v1607+ (Pro, Enterprise, Education)
  • Windows 11 (Pro, Enterprise, Education)


Disclaimer:

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

Batch Script

For example: To create a folder named ‘FolderA’ in the Desktop of the user Deborah, replace enter_folder_path with C:\Users\Deborah\Desktop\FolderA\

Remember to put a backslash after the folder name; else, it will search for a file rather than a folder.

PowerShell Script

Script to create a folder if it doesn’t exist on Windows remotely executed successfully from Hexnode.

To create a folder named ‘FolderA’ in the Desktop of the user Deborah, replace enter_folder_name_here with FolderA and replace enter_folder_path with C:\Users\Deborah\

If you want to create a folder with the folder name as that particular day’s date, replace enter_folder_name_here with (Get-Date).tostring(“dd-MM-yyyy”) without the double-inverted commas.

i.e., $folderName = (Get-Date).tostring(“dd-MM-yyyy”)

How to View Script Output in Hexnode

To review the execution results, navigate to the Action History tab of the specific device in your Hexnode UEM portal. Locate the script entry in the Subject column and click the Show Output button next to the status field to view the returned data.

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