Need to map drive letters based on info from csv file.

SAM2009
SAM2009 used Ask the Experts™
on
Hi,

I want to map drive letters based on info from csv file.

Like:

User,DriveLetter,Path
Sam,E,\\Servr01\TeamShared

That script I will put it in GPO when a user logon. Is there a PowerShell for that?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
The obvious question first: any special reason you're not using a Drive Map GPO with item level targeting based on group membership?
Look, for example, here:
Using Group Policy Preferences to Map Drives Based on Group Membership
https://blogs.technet.microsoft.com/askds/2009/01/07/using-group-policy-preferences-to-map-drives-based-on-group-membership/
That said, of course there is PowerShell for that:
$scriptFolder = Split-Path $MyInvocation.MyCommand.Path -Parent
Import-Csv -Path "$($scriptFolder)\DriveMap.csv" | Where-Object {$_.User -eq ENV:UserName} | ForEach-Object {
	& net.exe use "$($_.DriveLetter):" $_.Path
}

Open in new window

Edit: Fixed csv file name

Author

Commented:
Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial