Microsoft PowerShell Drives

Introduction to Microsoft PowerShell’s Drives

Learning how to map a network drive in PowerShell is much easier than the equivalent MapNetworkDrive in VBScript.

My biggest surprise with Get-PSDrive was that the registry appeared in the results. I was expecting a list of the local and network drive, but I had not anticipated HKLM or ENV amongst the catalog of drives available to PowerShell.

SolarWinds’ Network Performance Monitor will help you discover what’s happening on your network. This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.

What I like best is the way NPM suggests solutions to network problems. Its also has the ability to monitor the health of individual VMware virtual machines. If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.

In the context of a drive, PowerShell uses Get-Childitem to list the contents. You may wish to use dir, or you may prefer to leave the old DOS commands at the PowerShell door and learn the new style Verb-Noun pairs. Incidentally, it is worth remembering that all PowerShell nouns are singular, Microsoft is determined to enforce consistency wherever possible.

A handy command is set-location. Microsoft include a mapping for many old dos commands, therefore if you prefer, use the alias cd, rather than the modern set-location.

The Get-PSDrive command returned more items than I expected. In amongst the usual C:\ and D:\ drive letters was HKCU and Alias. By creating a new com object it’s possible to MapNetworkDrive just as you would with VBScript.