Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mapped drive friendly naming based on group membership

Status
Not open for further replies.

Rcheek

MIS
Jul 26, 2010
1
US
Hello all,

I have been tweaking MarkDmac's great login script (thanks Mark) to adapt to our environment. We are mapping the user and public drives based on group membership. This is because the current network is comprised of one domain, but multiple locations connected via VPN tunnels. Most locations have a DC that hosts the users public and User shares. The users don't travel to other locations, so this works well until we get MPLS sometime in the future. The drive mapping is working well, but I have been asked if we can have the script change the mapped names to something more user friendly.

I have seen the Add On Markdmac created for this task using drive mappings for all, but I'm having trouble deciphering it to apply it to the task of renaming the drives mapped based on group membership. That plus I'm not much of a "from scratch" scripter, so any assistance would be welcome.

Here is the part of the script that is mapping the drives based on group membership. One item to note is that since all the drives mapped are either a user folder or public, it can be simplified for renaming, meaning that all the public drive mappings can be named just public and same for the user drives.


'Now check for group memberships and map appropriate drives
'Note that this checks Global Groups and not domain local groups.
For Each GroupObj In UserObj.Groups
'Force upper case comparison of the group names, otherwise this is case sensitive.
Select Case UCase(GroupObj.Name)
'Check for group memberships and take needed action
'In this example below, ADMIN and WORKERB are groups.
'Note the use of all upper case letters as mentioned above.
'Note also that the groups must be Global Groups.
Case "LOCATION1 USERS"
WSHNetwork.MapNetworkDrive "P:", "\\Long-FQDN-for-location1\Public",True
WSHNetwork.MapNetworkDrive "U:", "\\Long-FQDN-for-location1\Users\"& UserString,True
Case "LOCATION2 USERS"
WSHNetwork.MapNetworkDrive "P:", "\\Long-FQDN-for-location2\Public",True
WSHNetwork.MapNetworkDrive "U:", "\\Long-FQDN-for-location2\Users\"& UserString,True
Case "LOCATION3 USERS"
WSHNetwork.MapNetworkDrive "P:", "\\Long-FQDN-for-location3\Public",True
WSHNetwork.MapNetworkDrive "U:", "\\Long-FQDN-for-location3\Users\"& UserString,True
Case "LOCATION4 USERS"
WSHNetwork.MapNetworkDrive "P:", "\\Long-FQDN-for-location4\Public",True
WSHNetwork.MapNetworkDrive "U:", "\\Long-FQDN-for-location4\Users\"& UserString,True
Case "LOCATION5 USERS"
WSHNetwork.MapNetworkDrive "P:", "\\Long-FQDN-for-location5\Public",True
WSHNetwork.MapNetworkDrive "U:", "\\Long-FQDN-for-location5\Users\"& UserString,True
Case "LOCATION6 USERS"
WSHNetwork.MapNetworkDrive "P:", "\\Long-FQDN-for-location6\Public",True
WSHNetwork.MapNetworkDrive "U:", "\\Long-FQDN-for-location6\Users\"& UserString,True
Case "TEST USERS"
WSHNetwork.MapNetworkDrive "P:", "\\Long-FQDN-for-location1\Public",True
WSHNetwork.MapNetworkDrive "U:", "\\Long-FQDN-for-location1\Users\"& UserString,True
End Select
Next

Rcheek
 
To create a friendly name use this for one drive
Code:
'Map The Drive
			WshNetwork.MapNetworkDrive "Z:", strFolderName ,True
			'Rename the drive
			zDrive = "Z:\"
			Set WshShell = CreateObject("Shell.Application")
			WshShell.NameSpace(zDrive).Self.Name = "My Folder"

or an array
Code:
'Now rename the mapped drives to a meaningful name
'===========================================================================================================
   Dim DriveArray( 4, 1 )
   DriveArray( 0, 0 ) = "L:\"
   DriveArray( 0, 1 ) = "User Data"
   DriveArray( 1, 0 ) = "N:\"
   DriveArray( 1, 1 ) = "Public"
   DriveArray( 2, 0 ) = "O:\"
   DriveArray( 2, 1 ) = "Software"
   DriveArray( 3, 0 ) = "P:\"
   DriveArray( 3, 1 ) = "Data"
   DriveArray( 4, 0 ) = "S:\"
   DriveArray( 4, 1 ) = "Some Name"


Set WshShell = CreateObject("Shell.Application")
For remap = 0 to UBound(DriveArray)

WshShell.NameSpace(DriveArray(remap,0)).Self.Name = DriveArray(remap,1)
Next

MCITP:EA/SA, MCSE, MCSA, MCDBA, MCTS, MCP+I, MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top