So, I'm a total n00b with powershell and as anyone starting out with something unfamiliar, currently my "love" for PS can only be expressed in expletives.
Anyway, having spent past 9 hours beating my head against the wall, I'm throwing in a towel.
Here's what I am trying to accomplish: On share \\server1\users$ I need to get a list of all folders where permission contains an unresolved SID, e.g. S-1...... This will help me identify all folders where I have to either clean up permissions or delete it, since user is no longer in AD and folder is not needed.
Simple, right? Well, every time script encounters a folder where I don't have permissions, it crashes with:
"GET-ACL Attempted to perform an unauthorized operation...".
I followed advise in here to http://blogs.technet.com/b/heyscriptingguy/archive/2009/09/14/hey-scripting-guy-september-14-2009.aspx help me parse paths and get permissions. I tried to make sense of this article, but it's all greek to me:
http://rkeithhill.wordpress.com/2009/08/03/effective-powershell-item-16-dealing-with-errors/
So,
1. What's the most effective way to dump permissions for folders
2. How to keep script from crashing each time it encounters a terminating error?
$FML = PowerShell