I'm looking for a way to recursively go through my entire file share ( fairly large 3TB of files ) and list out all files/folders that I don't have access to. Due to a migration and some errors on large paths ( more than 255 characters ) we've found some folders/files have lost all permissions, and need a way to find them all. Currently as a domain admin user, I can't list the permissions or owner. I can take control of it, and reset the permissions, but I have so many files/folders I'd like to output this to a CSV files or something.
I've tried the following :
get-childitem "\,\fileshare\f$\folder\etc" -recurse | get-acl
This seems to work perfectly, it gives me the ACLs of all the files/folders that exist and have proper permissions on them. But once it hits a folder that I don't have access to, I get the following error :
Get-Acl : Attempted to perform an unauthorized operation.
At line:1 char:133
+ get-childitem "\,\fileshare\f$\folder\etc" -re
curse | get-acl <<<<
+ CategoryInfo : NotSpecified: (:) [Get-Acl], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetAclCommand
These are the errors I'd like to log to a CSV/TXT file, and ignore all the rest of the permissions, it would be ideal if this could be outputted in more one line per error fashion as well.
Just wondering if anyone has an idea or hint on how I should proceed?
(Please note the paths above have commas in them on purpose to not resolve to a real path
\,\fileshare\f$\folder\etc)
Thanks!