Export (0) Print
Expand All
Expand Minimize

Converting the Windows Script Host MapNetworkDrive Method


Windows PowerShell


Definition: Adds a shared network drive to your computer system.

MapNetworkDrive


The truth is, Windows PowerShell doesn’t know how to map a network drive. Admittedly, you can use the New-PSDrive cmdlet to seemingly map a network drive within PowerShell; for example, this command creates a new PowerShell drive mapped to Z:


New-PSDrive -name Z -psprovider FileSystem -root \\atl-fs-001\public


This new PowerShell drive can be used exactly like any other mapped network drive as long as you are working in Windows PowerShell. Outside of PowerShell, however, this mapped drive is of no use: no one else, including the operating system, is even aware that it exists. That’s because this is a PowerShell drive and not a true mapped drive.

So is there a way to map a network drive from within PowerShell? Sure, as long as you’re willing to use the command-line utility Net.exe. The following command creates a real network drive (Z:), a drive mapped to \\atl-fs-001\public:


net use z: \\atl-fs-001\public



See conversions of other Windows Script Host methods and properties.
Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft