Mapping Drives

by Jan 13, 2015

PowerShell Version 3 and later

To permanently map a network drive, use New-PSDrive with the –Persist parameter. This parameter makes the drive visible outside PowerShell.

To really create a persistent network drive, also make sure you add –Scope Global. If New-PSDrive runs outside the global scope (i.e. within a script), the drive will be visible in File Explorer only for as long as the script runs.

This example code illustrates how to map a network drive:

New-PSDrive -Name k -PSProvider FileSystem -Root \\storage2\vid -Persist -Scope Global

Twitter This Tip! ReTweet this Tip!