Friday, July 8, 2011

Powershell - List All Folders and Subfolders

dir -recurse | Where-Object { $_.PSIsContainer } | ForEach-Object { $_.FullName }
First, you list everything from your current location. To filter out only folders, we then filter for PSIsContainer, a property that is always true for folders. Finally, we output each folders' full path.


Thursday, July 7, 2011

Powershell to get ACLs for folders and subfolders

I have been searching this for long time. Now i have found out

 dir -recurse | Where-Object { $_.PSIsContainer } | Get-Acl

dir -recurse - Is to get all folders and subfolders
$_.PSIsContainer  - Is to check whether the object is a directory or a file
Get-ACL - to get ACLs for folders