Powershell – Assign NTFS permission using Powershell via CSV

active-directoryntfspowershellwindows-server-2012-r2

I have a CSV file as below

Foldername———- Securitygroup

Folder1———- SG_Folder1-Access

Folder2———- SG_Folder2-Access

I need to assign permissions like below,

so Security Group " SG_Folder1-Access " will have modify access on "Folder 1"

Security Group " SG_Folder2-Access " will have modify access on "Folder 2"

I have 500 folders and their own security group and need to create a power shell script to assign permissions.

Any help would be much appreciated.

Thanks

Best Answer

You can try the following script:

$acl = Get-Acl "\\$servername\folderpath"

$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("domain\user or usergroup","Modify", "ContainerInherit, ObjectInherit", "None", "Allow")
$acl.AddAccessRule($rule)

$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("Users","Modify", "ContainerInherit, ObjectInherit", "None", "Allow")
$acl.AddAccessRule($rule)

Set-Acl "\\$servername\folderpath" $acl

Here are informative links for help. http://tomandersonpro.net/ntfs-permissions-with-powershell/

https://blogs.technet.microsoft.com/josebda/2010/11/12/how-to-handle-ntfs-folder-permissions-security-descriptors-and-acls-in-powershell/