Map drives and change their name.

Author Message
chrspe

  • Total Posts : 4
  • Scores: 0
  • Reward points : 0
  • Joined: 5/26/2008
  • Status: offline
Map drives and change their name. Monday, May 26, 2008 12:29 AM (permalink)
0
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.
 
#1
    SAPIENScripter

    • Total Posts : 283
    • Scores: 2
    • Reward points : 0
    • Joined: 11/1/2006
    • Location: SAPIEN Technologies
    • Status: offline
    RE: Map drives and change their name. Sunday, June 01, 2008 3:23 PM (permalink)
    0
    This is not really a PowerShell question.  If you haven't already post this in the VBScript forum.
    Jeffery Hicks
    Windows PowerShell MVP
    SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com

    Follow Me: http://www.twitter.com/JeffHicks
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9