How to view folder NTFS permission with PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

To view the NTFS permission with PowerShell, we use the Get-ACL command. This command is supported in PowerShell version 5.1 or later. Generally how we get the security permission of the folder in the Windows OS using GUI,

To get the same permissions shown above using PowerShell, use the below command.

Get-Acl C:\Shared


PS C:\> Get-Acl C:\Shared 
Directory: C:\ 
Path      Owner     Access 
----      -----     ------ 
Shared BUILTIN\Administrators NT AUTHORITY\SYSTEM Allow FullControl...

You can compare the first image with the above output. You can compare the Owner of the folder and it is Administrator, second part is the Access, to get all the users who have access on this folder by expanding property.

Get-Acl C:\Shared | Select -ExpandProperty Access

Let convert the above output in the table format to get a clear understanding of the output as shown in the first image.

Get-Acl C:\Shared | Select -ExpandProperty Access | ft -AutoSize

So you have everything that you can see in the first image of the folder security property like User rights, File System rights, Inherited or not, etc.

To view the specific user rights, you can filter with the username. For example,

Get-Acl C:\Shared | Select -ExpandProperty Access | where {$_.IdentityReference -like "*user*"} | ft -AutoSize

Similarly, you can also filter other properties like AccessControlType, IsInherited, etc.

raja
Published on 28-Sep-2020 08:08:33
Advertisements