These are a couple PowerShell scripts that took me 30 minutes to write to save me 30 seconds when mapping drives for users, hope it helps somebody.
This repository contains two PowerShell scripts to facilitate the mapping of network drives, either on a local system or remotely on another computer.
This script is used to map a network drive on a remote computer.
- Open PowerShell as an Administrator.
- Navigate to the directory containing the script.
- Run the script using the command:
.\map-remote.ps1
- Follow the prompts to enter:
- The remote computer's name
- The drive path you wish to map
- The drive letter you want to use
- Your username
- Your password
The script will map the drive and refresh the explorer process on the remote computer.
This script maps a network drive on the local machine.
- Open PowerShell as an Administrator.
- Navigate to the directory containing the script.
- Run the script using the command:
.\maplocal.ps1
- Follow the prompts to enter:
- The drive letter you want to use (ensure it's a single character)
- The folder path (UNC path, e.g.,
\\ServerName\SharedFolder
)
The script checks the validity of the drive letter, maps the drive, and provides feedback on whether the mapping was successful.
- PowerShell 5.1 or higher
- Administrative privileges on the computer where the scripts are run
Ensure you have the necessary permissions to map network drives on the machines involved.