This is a simple PowerShell script that will make it easy to map a network drive as a different user.
Before running the script below in PowerShell you need to change the following:
- If needed change -Name “Z” to another drive letter
- Replace \\REMOTESERVER\SHARE with the share path you want mapped
- Replace DOMAINNAME with your domain name
After you correctly change the script as described, you should be good to go.
Run the script and it will ask you to type in the username of the different user you want to use.
$Username = Read-Host -Prompt 'Type Username' #$Password = Read-Host -assecurestring 'Type Password' New-PSDrive -Name "z" -PSProvider "FileSystem" -Root "\\REMOTESERVER\SHARE" -Persist -Credential DOMAINNAME\$username