How do I get only directories using Get-ChildItem?

I’m using PowerShell 2.0 and I want to pipe out all the subdirectories of a certain path. The following command outputs all files and directories, but I can’t figure out how to filter out the files. Get-ChildItem c:\mypath -Recurse I’ve tried using $_.Attributes to get the attributes but then I don’t know how to construct … Read more

What’s the best way to determine the location of the current PowerShell script?

Whenever I need to reference a common module or script, I like to use paths relative to the current script file. That way, my script can always find other scripts in the library. So, what is the best, standard way of determining the directory of the current script? Currently, I’m doing: $MyDir = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition) I … Read more