- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to map the network drive using PowerShell?
You can map the network drive on the local and remote computers using several ways.
Using cmd command.
You can use the below command to map the network drive, here letter M, and the shared folder on the local computer.
Example
net use M: "\remoteshare\Shared Folder" PS C:\WINDOWS\system32> net use M: Local name M: Remote name \remoteshare\Shared Folder Resource type Disk Status OK # Opens 1 # Connections 1 The command completed successfully.
To map on the remote computer.
Invoke-Command -ComputerName RemoteComputer -ScriptBlock{net use k: "\remoteshare\shared"}
Using the New-PSDrive command.
You can map a network drive using Powershell command New-PSDrive on local and remote computers both.
To map a drive on the local computer.
New-PSDrive -Name K -PSProvider FileSystem -Root \remoteshare\shared -Persist
Output
PS C:\WINDOWS\system32> Get-PSDrive -Name K Name Used (GB) Free (GB) Provider Root ---- --------- --------- -------- ---- K 318.16 47.24 FileSystem \remoteshare\shared
To map a drive on the remote computer.
Invoke-Command -ComputerName Remotecomputer -ScriptBlock {New-PSDrive -Name K -PSProvider FileSystem -Root \remoteshare\shared -Persist}
- Related Articles
- How to remove the mapped network drive using PowerShell?
- How to change the Drive letter using PowerShell?
- How to remove pagefile on the specific drive using PowerShell?
- How to rename the drive letter in Windows using PowerShell?
- How to retrieve the Azure subnets connected to the virtual network using PowerShell?
- How to find a network adapter driver version using PowerShell?
- How to retrieve the Azure VM network security group (NSG) using PowerShell?
- How to get the Azure VM virtual Network and the Subnet name using PowerShell?
- JavaScript: How to map array values without using "map" method?
- How to get complete drive information using C#?
- How to format the disk using PowerShell?
- How to work the timezone using PowerShell?
- How to traceroute using PowerShell?
- How to search in the file using PowerShell?
- How to edit the CSV file using PowerShell?

Advertisements