[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 419
  • Last Modified:

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.
0
tballin
Asked:
tballin
1 Solution
 
Tony JLead Technical ArchitectCommented:
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.
0
 
pony10usCommented:
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>
0
 
Justin YeungCommented:
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
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
tballinAuthor Commented:
In the above script, it looks like I would just change paths, OU names and then put this into a .vbs file?
0
 
Justin YeungCommented:
Yes. and i missed
"Next"
on the last row
0
 
tballinAuthor Commented:
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

0
 
Justin YeungCommented:
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 ""
0
 
Justin YeungCommented:
remember strUserName = your logon

so the path will be \\Acme_1\tools\"username"

if the path is not right nothing will be mapped without error since "On Error Resume Next" is there

you can also take line 14 off and see if you have any error.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now