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.
Batch Script
| 1 2 3 4 5 6 7 8 9 | @echo off  cls  if not exist "enter_folder_path" (  mkdir "enter_folder_path"  echo Folder created.  ) else (  echo Folder already exists!  )  | 
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
| 1 2 3 4 5 6 7 8 9 10 11 | $folderName = “enter_folder_name_here”  $Path="enter_folder_path"+$folderName  if (!(Test-Path $Path))  {  New-Item -itemType Directory -Path enter_path -Name $FolderName  Write-host “Folder created.”  }  else  {  write-host "Folder already exists!"  }  | 
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\
| 1 2 3 4 5 6 7 8 9 10 11 | $folderName = “FolderA”  $Path="C:\Users\Deborah\"+$folderName   if (!(Test-Path $Path))  {  New-Item -itemType Directory -Path C:\Users\Deborah -Name $FolderName  write-host “Folder created.”  }  else  {  write-host "Folder already exists!"  }  | 
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”)