Easiest way to set permissions on a folder with PowerShell!

PowerShell Protect folder

I wanted to jot this down real quick because it has come in handy for me a few times. I wanted the easiest way to set permissions on a folder (recursively) and here is what I came up with.

$acl = Get-Acl c:\temp
$newACL = [Security.AccessControl.FileSystemAccessRule]::new( `
          'contoso\gene', `
          'Fullcontrol',  `
          'ContainerInherit,ObjectInherit', `
          'InheritOnly', `
          'Allow' )
$acl.AddAccessRule($newACL)
$acl | Set-Acl c:\temp

–Gene

Leave a Reply