Getting Explicit NTFS Permissions

by Jun 5, 2015

To find out which NTFS access permissions have been assigned directly to a file or folder, check for the property "isInherited". This will create a new folder "sampleFolderNTFS", then list all explicit NTFS permissions. Since you just created the folder, there will only be inherited permissions, so you will not get any results looking for explicit permissions:

$Path = 'c:\sampleFolderNTFS'

# create new folder
$null = New-Item -Path $Path -ItemType Directory -ErrorAction SilentlyContinue

# get permissions
$acl = Get-Acl -Path $path
$acl.Access |
  Where-Object { $_.isInherited -eq $false }

Once you add an explicit permission, the code will yield results. This is how you can add an explicit permission via PowerShell. It will add a new permission for the current user with read, write, and modify permissions:

$acl = Get-Acl -Path $path

# add a new permission
$permission = $env:username, 'Read,Write,Modify', 'ContainerInherit, ObjectInherit', 'None', 'Allow'
$rule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $permission

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

Twitter This Tip! ReTweet this Tip!