How to map network drive using PowerShell on Windows 10

Configurare noua (How To)

Situatie

Windows 10 provides multiple ways to map a network drive on your computer, including using PowerShell, which can come in handy when creating a script or when you prefer using a command-line interface.

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.

Solutie

Pasi de urmat
  • Open Start on Windows 10.
  • Search for PowerShell and click the top result to open the console.
  • Type the following command to map a drive assigning drive letter manually and press Enter:
New-PSDrive -Name "DRIVER-LETTER" -PSProvider "FileSystem" -Root "\\DEVICE-NAME-OR-IP\SHARED-FOLDER" -Persist
  • 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:
New-PSDrive -Name "E" -PSProvider "FileSystem" -Root "\\vm-beta\ShareOne" -Persist
Once you complete the steps, the network shared folder will map on the computer, and it will appear in File Explorer.

PowerShell map network drive on Windows 10
How to map network drive with credentials on PowerShell

To map a network drive providing the account name and password, use these steps:

  • Open Start.
  • Search for PowerShell and click the top result to open the console.
  • Type the following command to create a variable with the credentials you want to use and press Enter:
$cred = Get-Credential -Credential USERNAME
  1. Confirm your account password.
  2. Click the OK button.
  3. Type the following command to map a drive assigning drive letter manually and press Enter:
    New-PSDrive -Name "E" -Root "\\DEVICE-NAME-OR-IP\SHARED-FOLDER" -Persist -PSProvider "FileSystem" -Credential $cred

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:

New-PSDrive -Name "E" -Root "\\vm-beta\ShareOne" -Persist -PSProvider "FileSystem" -Credential $cred

PowerShell map network drive with password

Tip solutie

Permanent

Voteaza

(2 din 3 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?