Powershell how to get acls from files/directories recursively also including "[" or "]"
ntfs, permissions, powershell
Solution
I'm not sure this does 100% the same thing but I'm using the following one-liner
get-childitem "C:\windows\temp" -recurse | get-acl | Format-List | Out-File "c:\temp\output.txt"
Problem
I have the script below working for most of the files and folders but is not working for files and folders with "[" "]" ``` #Set variables $path = $args[0] $filename = $args[1] $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 #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" "-----------------------" | Out-File -FilePath "C:\Powershell\Results\$filename" -Append } #end ForEach ```