Category filter

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

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 10 devices if it doesn’t already exist by executing custom scripts via Hexnode UEM.

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

Example script:

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”)

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