Get Permissions on folders and subfolders using PowerShell

PowerShell Get-ACL available in Microsoft.PowerShell.Security module gets permissions on folders and subfolders. Windows OS stores information related to file, folder, and subfolders permission in Access Control List (ACL).

PowerShell provides a Get-ACL cmdlet that gets the access control list for the resource. The Access control list contains the users and users group permission to access the resource.

To get permissions on folder, use get-acl cmdlet

Get permissions on folder
Get permissions on folder

In this article, I will explain you how to get permissions on folders and subfolder and NTFS permission report as output file.

Get permissions on current working directory

To get NTFS permissions report on current working directory in PowerShell, use Get-ACL cmdlet without any parameters. It returns access control list for directory.

PS C:\Temp\>Get-ACL

In the above example, Get-ACL gets permissions on current working directory, here in C:\Temp.

Output of the Get-Acl gets permission on folder as below

PowerShell Get-ACL permissions on Current folder
PowerShell Get-ACL permissions on folder

Cool Tip: How to Get Current Directory in PowerShell !

Get NTFS permissions report on folder in format-table

To get output of PowerShell get-acl cmdlet on folder permissions in format-table, use below command

PS C:\Temp> Get-Acl | Format-Table -Wrap

Above command, gets the NTFS permission report on folders and outputs results to Format-Table. Output of the above command as below

powershell get acl on folder
Get-ACL folders permission in Format-table

Do you know: How to use equivalent of cat command in Windows !

Get permission on folders and subfolders recursively

Use below command to get permission on folders and subfolders using Get-ACL

PS C:\PowerShell\>Get-ChildItem -Recurse | where-object {($_.PsIsContainer)} | Get-ACL | Format-List

In the above PowerShell example, to get permissions on folders and subfolders recursively,

Get-ACL can’t return all folders and subfolders permission hence we need to use PowerShell Get-ChildItem cmdlet with -Recurse parameter.

Output of the the command pass through where-object{$_.PslsContainer} filter to select only folder. PsIsContainer get directory if its property in file system object set to true.

Later, using Get-ACL cmdlet gets permissions on folders and subfolders recursively.

Output of the above command list permissions on folder as given below

Get-ACL - Get permissions on folders and Subfolders
Get-ACL – Get permissions on folder and Subfolders

In case if you want to output folder permissions to a txt file, use below command

PS C:\Temp> Get-ChildItem -Recurse | where-object {($_.PsIsContainer)} | Get-ACL | Format-List | Out-File D:\folder-permission.txt

Above command, it get permission of folder and subfolders available in C:\Temp folder and gets permissions for that resource using Get-ACL and output results to D:\folder-permission.txt file.

Cool Tip: Check how to download zip file using PowerShell !

Conclusion

In the above blog post, I have shown you how to get NFTS permission report using PowerShell for folders and subfolders.

I hope you found above article on how to get permissions on folders and subfolders informative and educational.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on ShellGeek home page.

Leave a Comment