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.

From: http://powershell.com/cs/blogs/tips/archive/2009/07/22/list-all-folders-and-subfolders.aspx

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