Minggu, 13 Februari 2011

Powershell - Find Empty Folders in Directory Tree

I didn't create a whole lot here. I just used a Scripting Guys post and modified my search path. Here's the link:

http://technet.microsoft.com/en-us/library/ff730953.aspx
To get what I need I jump across a large set of folder trees:
dir \\192.168.0.2\a$\root\subname\*\storage | Where-Object {$_.PSIsContainer -eq $True} | Where-Object {$_.GetDirectories().Count -eq 0} | Select-Object FullName
This outputs a list of folders with no folders in them. If I wanted to tweak this to find folders without files, I wold use this pattern:
dir \\192.168.0.2\a$\root\subname\*\storage | Where-Object {$_.PSIsContainer -eq $True} | Where-Object {$_.GetFiles().Count -eq 0} | Select-Object FullName
This way I don't have to research this again. Now, I can just go back to my blog for posterity's sake

0 komentar:

Posting Komentar

 
Powered by Blogger