As I mentioned in my previous post, I am new to the PowerShell arena. I recently had a request to report the NTFS permissions on a Windows File Share and all it’s sub-directories. So I decided to see how I could get PowerShell to do this. After looking at multiple scripts and modifying them to suit my needs, I think I have a pretty decent solution to the request that was made.

SOLUTION

1) Copy the following code into a text editor and save the file as C:\PowerShell\GetAllACL.ps1



#Set variables

$path = Read-Host "Enter the path you wish to check"

$filename = Read-Host "Enter Output File Name"

$date = Get-Date #Place Headers on out-put file

$list = "Permissions for directories in: $Path"

$list | format-table | Out-File "C:\Powershell\Results\$filename"

$datelist = "Report Run Time: $date"

$datelist | format-table | Out-File -append "C:\Powershell\Results\$filename"

$spacelist = " "

$spacelist | format-table | Out-File -append "C:\Powershell\Results\$filename" #Populate Folders Array

[Array] $folders = Get-ChildItem -path $path -force -recurse | Where {$_.PSIsContainer} #Process data in array

ForEach ($folder in [Array] $folders)

{

#Convert Powershell Provider Folder Path to standard folder path

$PSPath = (Convert-Path $folder.pspath)

$list = ("Path: $PSPath")

$list | format-table | Out-File -append "C:\Powershell\Results\$filename" Get-Acl -path $PSPath | Format-List -property AccessToString | Out-File -append "C:\Powershell\Results\$filename" } #end ForEach



2) Open PowerShell

3) At the prompt, enter C:\PowerShell\GetAllACL.ps1

4) You will be prompted for the Path to the share or folder, enter as a UNC Path (\\server\share\folder)

5) You will next be prompted for the output file name. (Ex. share_folder_ACL.txt)

6) Check the output file for the results.

NOTES

Make sure C:\PowerShell\Results exists before running the script. Or if you modified the paths, make sure the directory structure is in place beforehand.

Make sure you follow the instructions in my first PowerShell post – PowerShell: Execution of Scripts is Disabled on This System