What is wrong with my script..... - TechRepublic
Question
September 12, 2008 at 06:28 AM
jsizer

What is wrong with my script…..

by jsizer . Updated 17 years, 10 months ago

O.k. I have create a login script and deployed it using GPO. If I put myself in each of the following groups I get the correct drive mappings at login. It returns a value for the group and maps the drives. However this doesn’t work for everyone. Some people get the right drives and some only get the G and H which everyone does get. There is something in the part about looking at the groups and I for the life of me cannot figure it out… I would appreciate any help! My boss thought he found something and you will see the part that we commented out, because if we put that in we get no group mappings working at all!

‘=========================================================================
‘ VBScript Source File — Created with XLnow OnScript

‘ AUTHOR:
‘ COMPANY:
‘ DATE: 8/6/2008
‘ COMMENT:
‘=========================================================================

Dim WshNet

WScript.Echo “The Script has started”

Set WshNet = WScript.CreateObject(“WScript.Network”)
On Error Resume Next
WshNet.RemoveNetworkDrive “g:”, True, True
Wscript.Sleep(1000)
WshNet.MapNetworkDrive “g:”, “\\cscifs1\common”
Set WSHNet = Nothing

Set WshNet = WScript.CreateObject(“WScript.Network”)
On Error Resume Next
WshNet.RemoveNetworkDrive “h:”, True, True
Wscript.Sleep(1000)

Dim objNetwork
Dim strDriveLetter, strRemotePath, strUserName
strDriveLetter = “h:”
strRemotePath = “\\cscifs1\home”

Set objNetwork = WScript.CreateObject(“WScript.Network”)
strUserName = objNetwork.UserName
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath & “\” & strUserName

Set WshNet = WScript.CreateObject(“WScript.Network”)
On Error Resume Next
WshNet.RemoveNetworkDrive “s:”, True, True
Wscript.Sleep(1000)

Set WshNet = WScript.CreateObject(“WScript.Network”)
On Error Resume Next
WshNet.RemoveNetworkDrive “t:”, True, True
Wscript.Sleep(1000)

Set WSHNet = Nothing

Dim objUser, CurrentUser
Dim strGroup

‘ Initialise Groups with Const
Const Engineering_Group = “cn=Sales Engineering”
Const Accounting_Group = “cn=Accounting”
Const ISA_Group = “ISATatamy”
Const IT_Group = “cn=IT”
Const Human_Resource_Group = “cn=HR”
Const Quality_Group = “cn=Quality Control”
const Marketing_Group = “cn=Marketing”
const IPC_Group = “cn=IPC”
const Purchasing_Group = “cn=Purchasing”
const MfgEng_Group = “cn=Mfg Eng”

Set objNetwork = CreateObject(“WScript.Network”)
Set objUser = CreateObject(“ADSystemInfo”)
Set CurrentUser = GetObject(“LDAP://” & objUser.UserName)

‘If ISArray(CurrentUser.Memberof) then
‘ strGroup = LCase(CurrentUser.MemberOf)
‘Else
strGroup = LCase(Join(CurrentUser.MemberOf))
‘End If

‘WScript.Echo strGroup

If InStr(strGroup, lcase(Engineering_Group)) Then

objNetwork.MapNetworkDrive “s:”, “\\cscifs1\Engineering”
objNetwork.MapNetworkDrive “z:”, “\\cscifs1\common”

ElseIf InStr(strGroup, lcase(ISA_Group)) Then

objNetwork.MapNetworkDrive “s:”, “\\cscifs1\isa”

ElseIf InStr(strGroup, lcase(IT_Group)) Then

objNetwork.MapNetworkDrive “s:”, “\\cscifs1\it”

ElseIf InStr(strGroup, lcase(Accounting_Group)) Then

objNetwork.MapNetworkDrive “s:”, “\\cscifinsrv\fingroup”
objNetwork.MapNetworkDrive “t:”, “\\cscifinsrv\finance”

ElseIf InStr(strGroup, lcase(Quality_Group)) Then
objNetwork.MapNetworkDrive “s:”, “\\cscifs1\quality”

ElseIf InStr(strGroup, lcase(Marketing_Group)) Then
objNetwork.MapNetworkDrive “s:”, “\\cscifs1\marketing”

ElseIf InStr(strGroup, lcase(Human_Resource_Group)) Then
objNetwork.MapNetworkDrive “s:”, “\\cscifs1\hr”

ElseIf InStr(strGroup, lcase(IPC_Group)) Then
objNetwork.MapNetworkDrive “s:”, “\\cscifs1\IPC”

ElseIf InStr(strGroup, lcase(Purchasing_Group)) Then
objNetwork.MapNetworkDrive “s:”, “\\cscifs1\purchasing”

ElseIf InStr(strGroup, lcase(MfgEng_Group)) Then
objNetwork.MapNetworkDrive “s:”, “\\cscifs1\Engineering”

End If

WScript.Echo “The script has ended”
WScript.Quit

This discussion is locked

All Comments