How to Map Network Drives Using PowerShellIn years past, automatic map network drives required the use of primitive batch files, luckily for us you can now do it through PowerShell.
Using a mapped network drive, you can very quickly access files and folders on a shared network as if they were on your local workstation.
Before the PowerShell era, we could map networks drives using a batch file that contained a net use command:
net use M: \\nasserver\Share /Persistent:Yes
To map network drives in PowerShell, open up your favourite terminal application and enter the following command to map network drives.
New-PSDrive -Name "M" -PSProvider FileSystem -Root "\\nasserver\share" -Persist
You can roll this into a PowerShell script which you can double-click on the desktop or add to startup if you wish.
If you want to manually map a network drive, simply open File Explorer and right-click "This PC" on the left-hand side of the window. Select the option "Map Network Drive", enter the network drive address and select the letter you want to map it to, then click on finish. You can also check the box which says "Reconnect at Login" to keep the drive visible after rebooting, otherwise you will have to map it again.