When you use PowerShell (or any other methods, such as Command Prompt or File Explorer) to map a network-shared folder, the process will create a pointer to the destination folder that will appear in File Explorer as a drive with the letter you assigned it. This guide will teach you how to use PowerShell to map a network drive on Windows 10. In addition, we will outline the steps to disconnect the mapping when it is no longer needed.
Map network drive on PowerShell Map network drive with credentials on PowerShell Disconnect mapped network drive on PowerShell
Map network drive on PowerShell
To map a network drive with PowerShell, use these steps: Once you complete the steps, the network shared folder will map on the computer and appear in File Explorer. In the command, replace DRIVER-LETTER with the drive letter not already in use you want to use. Then change DEVICE-NAME-OR-IP and SHARED-FOLDER for the name of the computer name or IP address of the device hosting the shared folder and the name of the shared. For example, this command maps the ShareOne folder to the computer with the “E” drive letter:
Map network drive with credentials on PowerShell
To map a network drive providing the account name and password, use these steps: After you complete the steps, the command will authenticate and map the shared folder as a drive on Windows 10.
In the command, replace DRIVER-LETTER with the drive letter not already in use you want to use. Then change DEVICE-NAME-OR-IP and SHARED-FOLDER for the name of the computer name or IP address of the device hosting the shared folder and the name of the shared. For example, this command maps the ShareOne folder to the computer with the “E” drive letter:
When connecting using credentials, you will always get prompted to provide a password manually. If you want to avoid this step, you could store the password in an encrypted file on the computer and query that file using PowerShell. Or you can speed up the process by storing the remote host account name and password in Credential Manager and then use the same command without the -Crendtial option like this: New-PSDrive -Name “E” -Root “\vm-beta\ShareOne” -Persist -PSProvider “FileSystem” You can create a new entry in Credential Manager using this command: cmdkey /add:pcname /user:network\username /pass:password
Disconnect mapped network drive on PowerShell
To disconnect and remove a mapped network drive with PowerShell, use these steps: Once you complete the steps, the drive mapping will be removed from the computer. In the command, replace DRIVE-LETTER with the drive letter of the mapping. For example, this command disconnects the “E” drive:
In the command, replace DRIVER-LETTER-1 and DRIVE-LETTER-2 with the drive letters you want to disconnect. For example, this command disconnects the “E” and “F” drives: All content on this site is provided with no warranties, express or implied. Use any information at your own risk. Always backup of your device and files before making any changes. Privacy policy info.