Removing Explicit NTFS Permissions

by Jun 8, 2015

In previous examples, we showed you how you can add new NTFS permissions to an existing folder. If you want to reset permissions and make sure all previously present explicit NTFS permissions are removed, here is code that removes all existing permissions:

# make sure this folder exists 
$Path = 'c:\sampleFolderNTFS'

# get explicit permissions
$acl = Get-Acl -Path $path
$acl.Access |
  Where-Object { $_.isInherited -eq $false } |
  # ...and remove them
  ForEach-Object { $acl.RemoveAccessRuleAll($_) } 

# set new permissions
$acl | Set-Acl -Path $path 

Twitter This Tip! ReTweet this Tip!