PowerShell TMTOWTDI

For practice, I've started converting the Hey, Scripting Guy! articles into PowerShell like Mow has. I'm starting to see that PowerShell gives you a Perl-like flexibility of doing things more than one way.

For example, Mow's solution to store directories inside an array was to test with the psIsContainer property. My solution was to use each item's getType() method:

get-childitem -recurse . | where  { $_.gettype().name -eq "DirectoryInfo" }

The results are the same, but the methods to reach them highlight a difference in thinking. It was just natural for me to test against the type of object rather than a property of it. This kind of flexibility is perfect in an automated / agile System Administration environment: never once have I been restricted to how I obtain a solution as long as the solution is correct.