Istanbul/Turkey

Create folders according to the username and set NTFS permissions

The below script creates user folder with their corresponding name and set the fullcontrol access right to that user for his folder.

So, testuser01 user will have full access right on the testuser01 folder.   

 

 

Create a csv file in the format below. Name it "File.csv"

 

User,Perm,Rule

 testuser01,FullControl,Allow

 testuser02,FullControl,Allow

 testuser03,FullControl,Allow

 

 

Then create a ps1 file and add the following lines in it. Copy "File.csv" into d:\Adalet path. 

cls

Set-Location "D:\Adalet"

$pfad = "D:\Adalet"

$Folders = Import-Csv "d:\Adalet\File.csv"

ForEach ($Folder in $Folders) {

New-Item $Folder.User -type directory

$Dir = $Folder.User

$User = $Folder.User

$Perm = $Folder.Perm

$Rule = $Folder.Rule

$ACL = Get-Acl "$Pfad\$Dir"

$ACL.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule("$User", "$Perm", "ContainerInherit, ObjectInherit", "None", "$Rule")))

Set-Acl "$pfad\$dir" $Acl

 

}

  • Hits: 2944