
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Map 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}
Advertisements