Thursday, January 24, 2013

PowerShell: Listing files/directories only

In DOS, it is always easy to find only directories or only files,

For example,

will display only directories. If you want to display just files, you can do this,

Ironically, PowerShell which is more powerful and modern than DOS, it is not very straightforward to do this.

In PowerShell 2.0 you have couple of not very straightforward options,

Do this no more, PowerShell 3.0 is here with the fix, Now it has two new switches –File,–Directory

PowerShell 3.0 also comes with –Attribute switch to do make it even more powerful.