Updating NTFS Permissions in Powershell

I recently encountered a situation on a 4TB drive that needed permissions added recursively to a large directory with many folders. To save time I created a powershell script that would do this for me. Below is the script:

 

 

$path = "C:\yourpath\"
$user = "domain\username"
$permission = "Modify"
$acl = Get-Acl $path
$inherit = [system.security.accesscontrol.InheritanceFlags]"ObjectInherit",[system.security.accesscontrol.InheritanceFlags]"ContainerInherit"
$propagation = [system.security.accesscontrol.PropagationFlags]"None"
$accessRule = New-Object system.security.AccessControl.FileSystemAccessRule($user, $permission, $inherit, $propagation, "Allow")
$acl.SetAccessRule($accessRule)
$acl | Set-Acl $path

Leave a Reply

Your email address will not be published. Required fields are marked *

4 × two =