| |
chrspe
Posts: 3
Score: 0
Joined: 5/25/2008
Status: offline
|
Hi. I'm totaly new to this with scripting and I have some questions. I would like to have a script that map drives trough user login in AD and map certain drives based on witch group the user is a member in (i.e users in group production get X: mapped to \\server1\prod) And the mapped drive should change name to what I give it (i.e from "prod on server1 (X:)" to just Prod (X:)). I would like to map the home directory to the specific user, i.e H: to \\server1\users\xxxxxx, to Home (H:). (xxxxxx being the user login and homedirectory) I now have AD to map home directory on every user, should I clear the field that maps this drive and type it in the script? If not, how can i rename it? I've come across several vbs-script that does this but i can't get them to work together in just one script. These are the two scripts that I've been looking at: First the user-based: -------------------- On Error Resume Next Set objSysInfo = CreateObject("ADSystemInfo") Set objNetwork = CreateObject("Wscript.Network") strUserPath = "LDAP://" & objSysInfo.UserName Set objUser = GetObject(strUserPath) For Each strGroup in objUser.MemberOf strGroupPath = "LDAP://" & strGroup Set objGroup = GetObject(strGroupPath) strGroupName = objGroup.CN Select Case strGroupName Case "Sales" objNetwork.MapNetworkDrive "Z:", "\\server1\Sales" Case "Prod" objNetwork.MapNetworkDrive "G:", "\\server1\Prod" End Select Next ---------------------- Then for name change: ---------------------- Option Explicit Dim objNetwork, strRemotePath1, strRemotePath2, strRemotePath3, strRemotePath4 Dim strDriveLetter1, strDriveLetter2, strDriveLetter3, strDriveLetter4 Dim strNewName1, strNewName2, strNewName3, strNewName4 Dim objShell strDriveLetter1 = "K:" strDriveLetter2 = "S:" strDriveLetter3 = "T:" strDriveLetter4 = "X:" strRemotePath1 = "\\server1\ftproot" strRemotePath2 = "\\server2\Mail" strRemotePath3 = "\\server1\All" strRemotePath4 = "\\server1\Pic" strNewName1 = "FTP" strNewName2 = "Mail" strNewName3 = "All" strNewName4 = "Pictures" Set objNetwork = CreateObject("WScript.Network") ' Section which maps 4 drives, K:, S:, T:, X: objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1 objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2 objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3 objNetwork.MapNetworkDrive strDriveLetter4, strRemotePath4 Set objShell = CreateObject("Shell.Application") objShell.NameSpace(strDriveLetter1).Self.Name = strNewName1 objShell.NameSpace(strDriveLetter2).Self.Name = strNewName2 objShell.NameSpace(strDriveLetter3).Self.Name = strNewName3 objShell.NameSpace(strDriveLetter4).Self.Name = strNewName4 ' Extra code just to add a message box 'WScript.Echo "Map drives " & strDriveLetter1 & " & " & strDriveLetter2 Wscript.Quit ------------------- Is it possible to combine them into one? And how to change the name on the home directory? Thanks.
|
|