Adding New PowerShell Drives

by Jun 17, 2011

You can add a bunch of interesting new drives to PowerShell with just a single line of code:

[System.Enum]::GetNames([System.Environment+SpecialFolder]) |
ForEach-Object {
New-PSDrive -Name ($_) -Root ([System.Environment]::GetFolderPath($_))
-PSProvider FileSystem }

Care to see your desktop files? Try this:

Dir Desktop:

Want to see your cookies? There’s this:

Dir Cookies:

Want to get rid of cookies? Try this:

Del Cookies:

Find Music? There’s this:

Dir MyMusic:

You can also add this line to your PowerShell profile ($profile) to make these drives permanent in PowerShell.


Twitter This Tip!
ReTweet this Tip!