Question

Locked

What is wrong with my script.....

By jsizer ·
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: <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 conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Don't know much scripting but:

by 1bn0 In reply to What is wrong with my scr ...

Your script looks a little more complicated than may be necessary.

I have had good luck using The Logon Script Generator from Sapien Technologies.

http://www.sapien.com/download.aspx?file=logonhta

It is an HTA (HyperTextApplication). You do need to edit the drives.txt and printers.txt files to list your available shares and printers, before using the program.

Collapse -

Thank you but that doesn't help

by jsizer In reply to Don't know much scripting ...

I don't really want to re-invent. I know that this script works for some people but not others. The common link seems to be if you are in more then one security group on the domain. I just cannot pin point what it is that is causing this to not return a value when the user is only in the group they are supposed to be. Or that when I change my group I am fine and only in ONE group. So my theory gets flushed when I realized that. I am at a complete loss...

Jenn

Collapse -

I may be confused but,

by IC-IT In reply to Thank you but that doesn' ...

Are you stating that it does not work if you are in more than one group?
If so than that is because the ElseIf has been met.
You may want to look at IsMemberOf or just an If Then.

Collapse -

This might help you with your scipt...

http://www.sophos.com/support/knowledgebase/article/13273.html

Please post back if you have any more problems or questions.
If this info is useful, please mark it helpful. Thanks

Back to Hardware Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums