-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapdrives.ps1
More file actions
17 lines (13 loc) · 775 Bytes
/
mapdrives.ps1
File metadata and controls
17 lines (13 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Apply network drive mappings based on group, meant to be used with an active directory GPO.
# Copyright (c) 2015 Dion Mitchell
# License Apache 2.0
# information for users, drives to map and network share path are stored here
$driveMappings = @{
'Technicians' = @{'path' = '\\svr.home.lan\techs'; 'letter' = 'T:' };
'Directors' = @{'path' = '\\svr.home.lan\dirs'; 'letter' = 'B:' }
}
$netObj = New-Object -ComObject "Wscript.Network"
$dsSearch = (New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=$($env:username)))")).FindOne().GetDirectoryEntry().memberOf
$driveMappings.GetEnumerator() | % {
if($dsSearch -like "*CN="+ $_.key +",*"){ $netObj.MapNetworkDrive($_.value.letter, $_.value.path) }
}