Mapping Network Drive Using PowerShell On Windows 10: Have you had trouble mapping your network drive on the PC? Well, it’s a problem that should trouble you no more because windows 10 has several ways to fix the issue. However, we shall only focus on how to map a network drive using PowerShell, a windows’ powerful tool for command line and script writing.
You can create a pointer to the destination folder and appear on the file explorer With a name assigned to it through PowerShell. This page will look at how to use PowerShell to map a network drive on windows 10.
Map network drive on PowerShell
- Press the Windows key + R key
- Type PowerShell and hit the Enter Key
- On the PowerShell window, type New-PSDrive -Name “DRIVER-LETTER” -PSProvider “FileSystem” -Root “\\DEVICE-NAME-OR-IP\SHARED-FOLDER” -Persist to map a network drive on a PC. From the command line, change DRIVER-LETTER with a later not used already. Next, substitute DEVICE-NAME-OR-IP with the name of the Device hosting the shared folder. For instance, you can use
New-PSDrive -Name “E” -PSProvider “FileSystem” -Root “\\vm-beta\ShareOne” -Persist
Where E is the drive name, vm-beta is the name of the Device hosting the shared folder, and the shared folder is ShareOne
Map network drive with credentials on PowerShell
You can also map a network drive that provides credentials like password and account name. to do this, follow the steps below.
- Press the Windows key + R key
- Type PowerShell and hit the Enter Key
- Copy and paste the following command on the PowerShell console
- $cred = Get-Credential -Credential USERNAME
- Hit the Enter Key
- Confirm the account password and press the Ok button
- Now type the command New-PSDrive -Name “E” -Root “\\stephenmaryson\PE modules” -Persist -PSProvider “FileSystem” -Credential $cred. E is the driver letter, Stephenmaryson is the device name, and PE modules are the shared folder. Remember to change these according to your computer.
Once you com-let these steps, the shared folder will be authenticated and mapped as a drive on a windows 10 PC.
However, if you want to connect the drive using the username and password, you’ll always be required to manually key in the password. But you can store your password in an encrypted file to avoid entering the password manually every time.
The stored File can be queried in PowerShell. If this is still a bother, speed up the entire process by keeping the remote host account name & password within the credential manager; after that, use the command.
New-PSDrive -Name “E” -Root “\\vm-beta\ShareOne” -Persist -PSProvider “FileSystem.”
From here, create a new entry in the credential manager using the command
cmdkey /add:pcname /user:network\username /pass:password
Disconnect mapped network drive on PowerShell
Follow these steps to disconnect the mapped network drive from your PC using PowerShell.
- Press the windows key
- Type PowerShell and click to open the PowerShell console from the list provided
- Copy, paste, and run the Get-PSDrive -PSProvider “FileSystem” command. This will provide a list of all mapped network drives.
- On the next line of command, paste the command Remove-PSDrive -Name DRIVE-LETTER and run it. Substitute DRIVE-LETTER with the name of your mapped drive
- If there are multiple mapped drives, then you can use the command Get-PSDrive E, F | Remove-PSDrive, where E and F are the mapped network drive names.
These commands remove network drive mapping from your PC altogether.
We are not affiliated/associated with Microsoft who own Windows. “Windows” is a trademark of Microsoft Corporation.
The information contained on this website is for general information purposes only and any reliance you place on such information is strictly at your own risk.
Contact Microsoft Office
India | +91 N/A N/A | (0)80 4010 3000 1 800 572 1100 1 800 102 1100 |
United States | +1 +1 | (800) 642 7676 (800) 892 5234 (TTY) |