I need a list of directory paths that start c:\t2\ and end in \bad with varying folder structure. I tried this but it does not work.
Set-Location C:\T2\postoffices
Get-ChildItem . | where{$_.Psiscontainer} -eq "C:\T2\postoffices\*\bad" | select name >> c:\list.txt