Link to home
Start Free TrialLog in
Avatar of tballin
tballin

asked on

Logon Script Help

Is there a way to create a single log-on script for all users in a domain, but that are at three different sites (And who have home folders that exist on three different servers)?

I tried using the %HomeShare% and %HomePath%, but so far no luck.
Avatar of Tony J
Tony J
Flag of United Kingdom of Great Britain and Northern Ireland image

You could always set a system variable on the servers in each site and then use that in your scripts.

Another alternative might be to use %LOGONSERVER% but this could be a server outside of their site in some cases.
You could create a group for each site and use the if member:

@echo off
ifmember "site1"
if errorlevel 1 goto site1
ifmember "site2"
if errorlevel 1 goto site2
site3:
<enter commands>
goto all
site1:
<enter commands>
goto all
site2:
<enter commands>
goto all
all:
<enter commands>
or you can do it by OUs

Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
Set mappedDrives = objNetwork.EnumNetworkDrives  
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set Printers = WshNetwork.EnumPrinterConnections
strUserName = objNetwork.UserName
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)

For Each strGroup in objUser.MemberOf
strGroupPath = "LDAP://" & strGroup
Set objGroup = GetObject(strGroupPath)
strGroupName = objGroup.CN
On Error Resume Next

Select Case strGroupName
' The following are drives mapping OU
Case "OU1"
ObjNetwork.MapNetworkDrive "M:", "\\Server1\HOME\" & strUserName

Case "OU2"
ObjNetwork.MapNetworkDrive "M:", "\\Server2\HOME\" & strUserName
Avatar of tballin
tballin

ASKER

In the above script, it looks like I would just change paths, OU names and then put this into a .vbs file?
Yes. and i missed
"Next"
on the last row
Avatar of tballin

ASKER

Got a few errors at first, but I think I've correct them.  However, when I run this script, nothing happens.  No errors and no mapped drives.
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
Set mappedDrives = objNetwork.EnumNetworkDrives   
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set Printers = WshNetwork.EnumPrinterConnections
strUserName = objNetwork.UserName
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)

For Each strGroup in objUser.MemberOf
strGroupPath = "LDAP://" & strGroup
Set objGroup = GetObject(strGroupPath)
strGroupName = objGroup.CN
On Error Resume Next

Select Case strGroupName
' The following are drives mapping OU
Case "IT" 
ObjNetwork.MapNetworkDrive "T:", "\\Acme_1\tools\" & strUserName

Case "Sales" 
ObjNetwork.MapNetworkDrive "M:", "\Acme\dfs\sales\" & strUserName

End Select
Next

Open in new window

put msgbox strGroupName on line 15

you will see popup of all the groups name that you are in.

see if the name comes up the same as your case ""
ASKER CERTIFIED SOLUTION
Avatar of Justin Yeung
Justin Yeung
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial