Use PowerShell to Loop Through Folders in a Library

Here is an example of using PowerShell to look through folders in a SharePoint Document Library.


if(-not(Get-PSSnapin | where { $_.Name -eq "Microsoft.SharePoint.PowerShell"}))
{
      Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$site = Get-SPweb "http://sharepointed.com/site/taco/"

$mList=$site.Lists["Shared Tacos"]

foreach($f in $mlist.Folders)
 {
 Write-Host $f.Name
 }

$site.dispose()