Re: Drive maping help
- From: "Marty List" <usenet@xxxxxxxxxxxx>
- Date: Wed, 29 Mar 2006 11:14:05 -0700
Jim,
Try this script, I think this is what you are asking for. There's probably a
faster/more efficient way of doing this, and personally I would use more
variable names, but this way should be easier to understand if you're just
getting started.
'===========================================
Option Explicit
Dim WSHNetwork
Set WSHNetwork = WScript.CreateObject("WScript.Network")
' Fix this next line if it wrapped, If .... Then should be on one line:
If CheckOUMembership(WSHNetwork.username,
"LDAP://OU=Accounting,OU=Departments,DC=domain,DC=com") Then
WScript.Echo "DEBUG: Mapping drive T:"
WSHNetwork.MapNetworkDrive "T:", "\\SERVER\Share$"
End If
WScript.Quit
Function CheckOUMembership(ByVal Account, ByVal OU)
CheckOUMembership = False
Dim objAccount, objDomain
Set objAccount = Nothing
Set objDomain = GetObject(OU)
For Each objAccount in objDomain
' The object class can be User, Group, Computer or Schema.
If UCase(objAccount.Class) = "USER" Then
'WScript.Echo "DEBUG: " & objAccount.Name & ": " & objAccount.FullName
CheckOUMembership = True
Exit For
End If
Next
End Function
'===========================================
"Jim" <Jim@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E66E1A75-BCDB-4C57-A2D4-A37EC272B766@xxxxxxxxxxxxxxxx
Al
Thank you; you deciphered what I needed perfectly
One last question to solve the issue of the user being in multiple groups is
it possible instead to use the Organizational Units name to setup the T: map?
Thanks again
Jim
"Al Dunbar [MS-MVP]" wrote:
"Jim" <Jim@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0E2D6115-AF77-4B01-95C2-B05D40104404@xxxxxxxxxxxxxxxx
when a user logs in i would like this script to run as part of a Grouppolicy
to automatically map drive T and V for every user. also is it possible to
change the groupname variable
hold on, your script does not reference a groupname variable.
so that if for example the groupname = "PR_grp"
that the T: drive is mapped to \\servername\Payroll
=========
Dim WSHNetwork
Set WSHNetwork = WScript.CreateObject("WScript.Network")
WSHNetwork.MapNetworkDrive "T:", "\\Servername\Groupname"
WSHNetwork.MapNetworkDrive "V:", "\\Servername\logonname"
As written, the above code will map a share whose name is, literally
"groupname" on a server whose name is "servername" to drive T: and to
similarly map a share whose name is "logonname".
If your intention is that the actual sharenames differ from user to user,
the simplest one to implement is V:
WSHNetwork.MapNetworkDrive "V:", "\\Servername\" & WSHNetwork.username
If the user account is named "ElmerFudd", then V: would map to
\\Servername\ElmerFudd.
This is pretty straightforward, because the concept: "name of current user"
is understood by all parties. What is not clear is what you refer to as
"groupname", as this has no particular meaning here.
What I suspect you want is along these lines:
if user is in the group named "PR_grp" then
map T: to \\servername\Payroll
elseif user is in the group named "FI_grp" then
map T: to \\servername\Finance
... etc ...
The trouble is that there is nothing to constrain ones group memberships to
only one of a set number of groups. What should T: map to, for example, when
the user is found to be a member of PR_grp and FI_grp?
/Al
==========into
the servername i will fill in. what i need help with is Groupname and
Username so i dont have to create over 200 of these for all of our users.
after thinking a little more on this the groupname should be the OUname as
they could be a member of many groups but only one OU
jim
"Marty List" wrote:
Explain what you mean by "insert". To me that means type or paste it
passNotepad, but I doubt that's what you need help on :) Are you trying to
Do youvariables to the script on the command line?
When you say "a script", which scripting language are you referring to?
already have a script or a sample you're working with?
"Jim" <Jim@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D7FE7947-06BC-4972-82C8-EE4428899FD8@xxxxxxxxxxxxxxxx
is there a way to insert the user and group name into a script to map
network drives?
thanks
Jim
.
- Follow-Ups:
- Re: Drive maping help
- From: Al Dunbar [MS-MVP]
- Re: Drive maping help
- References:
- Re: Drive maping help
- From: Marty List
- Re: Drive maping help
- From: Al Dunbar [MS-MVP]
- Re: Drive maping help
- From: Jim
- Re: Drive maping help
- Prev by Date: Re: [MSH]about cmdlet's hidden parameter's question
- Next by Date: Re: Retrieve User Name
- Previous by thread: Re: Drive maping help
- Next by thread: Re: Drive maping help
- Index(es):
Relevant Pages
|