Logon Scripting

Associate
Joined
3 Jan 2007
Posts
224
Location
Surrey
Anyone expierienced with Logon Scripts?

Need to create a IF Member Script.

Got Three printers & Want to set a certain one default if member of a certani group.

I.e. If a member of Group 'Reception' Use \\Server\Printer 1 as Default But also Map \\Server\Printer 2 & \\Server|Printer 3

If a member of Group 'Admin' Use \\Server\Printer 2 as default but also map Printer 1 & 3

Just cannot get my head around IF Member scripts, any pointers or example scripts would be great!
 
I use this code in our logon script:

Function code:

Function IsMember(objADObject, strGroup)

' Function to test for group membership.
' objGroupList is a dictionary object with global scope.

If IsEmpty(objGroupList) Then
Set objGroupList = CreateObject("Scripting.Dictionary")
End If
If Not objGroupList.Exists(objADObject.sAMAccountName & "\") Then
Call LoadGroups(objADObject, objADObject)
objGroupList(objADObject.sAMAccountName & "\") = True
End If
IsMember = objGroupList.Exists(objADObject.sAMAccountName & "\" _
& strGroup)
End Function

And the code to use the function:

If IsMember(objUser, "GOUPNAME") Then
<Insert what you want to do here>
End If
 
Thanks for your help but ended up getting it working with this Script:

Code:
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
DomainString = Wshnetwork.UserDomain
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")

UserString = WSHNetwork.UserName
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

strComputer = WSHNetwork.ComputerName

For Each GroupObj In UserObj.Groups

    Select Case UCase(GroupObj.Name)
	Case "GROUP1"
            WSHNetwork.SetDefaultPrinter "\\Server\Printer 1"
        Case "GROUP2"
            WSHNetwork.SetDefaultPrinter "\\Server\Printer 2"
	Case "GROUP3"
            WSHNetwork.SetDefaultPrinter "\\Server\Printer 3"
	Case "GROUP4"
            WSHNetwork.SetDefaultPrinter "\\Server\Printer 4"
    End Select
 
Back
Top Bottom