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