This is Admin Script to create folders and subfolders and assigned with NTFS permission.
I notice that there is such request from a user in Technet Forum on how to generate folders with NTFS permission using script.
The request is to use VBScript, but I think for fast and simplified approach, Windows Batch for creating folder and ICACLS for NTFS permission are the easiest approach to complete this task.
Steps
- Save All Admin Scripts in the root of folders to be created
-
Open Command Prompt in Administrator mode
-
Execute “YLNotes__CreateFolderWithNtfsPerm.cmd”
-
If you wish to save to a log file for review, pipe the command to log file.
C:\> YLNotes__CreateFolderWithNtfsPerm.cmd > log.txt
Sample Log
Processing Folder [1] ------------------------------------------------------------------------- Path: [Folder 1\Folder 1.1\Folder 1.1.1] ICACLS Permission ------------------------------------------------------------------------- - Inheritance Value: r - remove all inherited ACEs - NTFS Permission : M - modify access - Grant to : users ICACLS CMD ------------------------------------------------------------------------- ICACLS "F:\YLNotes__CreateFolderWithPerm\Folder 1\Folder 1.1\Folder 1.1.1" /inheritance:r /grant "users:(CI)(OI)M" processed file: F:\YLNotes__CreateFolderWithPerm\Folder 1\Folder 1.1\Folder 1.1.1 Successfully processed 1 files; Failed processing 0 files ========================================================================= Processing Folder [2] ------------------------------------------------------------------------- Path: [Folder 1\Folder 3] ICACLS Permission ------------------------------------------------------------------------- - Inheritance Value: r - remove all inherited ACEs - NTFS Permission : M - modify access - Grant to : users ICACLS CMD ------------------------------------------------------------------------- ICACLS "F:\YLNotes__CreateFolderWithPerm\Folder 1\Folder 3" /inheritance:r /grant "users:(CI)(OI)M" processed file: F:\YLNotes__CreateFolderWithPerm\Folder 1\Folder 3 Successfully processed 1 files; Failed processing 0 files ========================================================================= Processing Folder [3] ------------------------------------------------------------------------- Path: [Folder 1\Folder 7\Folder 7.1] ICACLS Permission ------------------------------------------------------------------------- - Inheritance Value: r - remove all inherited ACEs - NTFS Permission : M - modify access - Grant to : users ICACLS CMD ------------------------------------------------------------------------- ICACLS "F:\YLNotes__CreateFolderWithPerm\Folder 1\Folder 7\Folder 7.1" /inheritance:r /grant "users:(CI)(OI)M" processed file: F:\YLNotes__CreateFolderWithPerm\Folder 1\Folder 7\Folder 7.1 Successfully processed 1 files; Failed processing 0 files ========================================================================= Processing Folder [4] ------------------------------------------------------------------------- Path: [Folder 1\Folder 7\Folder PC#] ICACLS Permission ------------------------------------------------------------------------- - Inheritance Value: r - remove all inherited ACEs - NTFS Permission : M - modify access - Grant to : users ICACLS CMD ------------------------------------------------------------------------- ICACLS "F:\YLNotes__CreateFolderWithPerm\Folder 1\Folder 7\Folder PC#" /inheritance:r /grant "users:(CI)(OI)M" processed file: F:\YLNotes__CreateFolderWithPerm\Folder 1\Folder 7\Folder PC# Successfully processed 1 files; Failed processing 0 files =========================================================================
How it works
- The script contain Folders Data File where the folders data to populated
-
The output of the log file to be generated into text file FOLDERS_DATA.txt
The example of the contents:
r|M|users|Folder 1\Folder 1.1\Folder 1.1.1
r|M|users|Folder 1\Folder 3
r|M|users|Folder 1\Folder 7\Folder 7.1
r|M|users|Folder 1\Folder 7\Folder PC#
- The Folders Path is generated and NTFS assigned on the leave of the folders.
For example, “Folder 1\Folder 1.1\Folder 1.1.1”, NTFS to be assigned on last folder “Folder 1.1.1”
Admin Scripts
- [ddownload id=”905″] YLNotes__CreateFolderWithNtfsPerm ([ddownload_count id=”905″])