Thanks, I am using a VBS works a treat.. can do mapped drives etc as well.. Great!
' Mount Street Holdings - Deploy Network Printers by Group.
' Written By Adam Giddens agiddens@mshplc.com, 06/01/05
'
Dim WSHNetwork
Dim FSO
Dim strUserName ' Current user
Dim strUserDomain ' Current User's domain name
Dim ObjGroupDict ' Dictionary of groups to which the user belongs
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set FSO = CreateObject("Scripting.FileSystemObject")
'
' Wait until the user is really logged in...
'
strUserName = ""
While strUserName = ""
WScript.Sleep 100 ' 1/10 th of a second
strUserName = WSHNetwork.UserName
Wend
strUserDomain = WSHNetwork.UserDomain
' Read the user's account "Member Of" tab info across the network
' once into a dictionary object.
Set ObjGroupDict = CreateMemberOfObject(strUserDomain, strUserName)
If MemberOf(ObjGroupDict, "General Floor Printer Users") Then
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen001"
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen002"
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen003"
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen004"
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen005"
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen006"
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen007"
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen008"
End If
If MemberOf(ObjGroupDict, "HDB-P-GEN001") Then
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen001"
WshNetwork.SetDefaultPrinter "\\hdb-sfl-01\hdb-p-gen001"
ElseIf MemberOf(ObjGroupDict, "HDB-P-GEN002") Then
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen002"
WshNetwork.SetDefaultPrinter "\\hdb-sfl-01\hdb-p-gen002"
ElseIf MemberOf(ObjGroupDict, "HDB-P-GEN003") Then
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen003"
WshNetwork.SetDefaultPrinter "\\hdb-sfl-01\hdb-p-gen003"
ElseIf MemberOf(ObjGroupDict, "HDB-P-GEN004") Then
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen004"
WshNetwork.SetDefaultPrinter "\\hdb-sfl-01\hdb-p-gen004"
ElseIf MemberOf(ObjGroupDict, "HDB-P-GEN005") Then
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen005"
WshNetwork.SetDefaultPrinter "\\hdb-sfl-01\hdb-p-gen005"
ElseIf MemberOf(ObjGroupDict, "HDB-P-GEN006") Then
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen006"
WshNetwork.SetDefaultPrinter "\\hdb-sfl-01\hdb-p-gen006"
ElseIf MemberOf(ObjGroupDict, "HDB-P-GEN007") Then
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen007"
WshNetwork.SetDefaultPrinter "\\hdb-sfl-01\hdb-p-gen007"
ElseIf MemberOf(ObjGroupDict, "HDB-P-GEN008") Then
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hdb-p-gen008"
WshNetwork.SetDefaultPrinter "\\hdb-sfl-01\hdb-p-gen008"
End If
If MemberOf(ObjGroupDict, "HDB-P-IT001") Then
WshNetwork.AddWindowsPrinterConnection "\\hdb-sfl-01\hbd-p-it001"
WshNetwork.SetDefaultPrinter "\\hdb-sfl-01\hbd-p-it001"
End If
Function MemberOf(ObjDict, strKey)
' Given a Dictionary object containing groups to which the user
' is a member of and a group name, then returns True if the group
' is in the Dictionary else return False.
'
' Inputs:
' strDict - Input, Name of a Dictionary object
' strKey - Input, Value being searched for in
' the Dictionary object
' Sample Usage:
'
' If MemberOf(ObjGroupDict, "DOMAIN ADMINS") Then
' wscript.echo "Is a member of Domain Admins."
' End If
'
'
MemberOf = CBool(ObjGroupDict.Exists(strKey))
End Function
Function CreateMemberOfObject(strDomain, strUserName)
' Given a domain name and username, returns a Dictionary
' object of groups to which the user is a member of.
'
' Inputs:
'
' strDomain - Input, NT Domain name
' strUserName - Input, NT username
'
Dim objUser, objGroup
Set CreateMemberOfObject = CreateObject("Scripting.Dictionary")
CreateMemberOfObject.CompareMode = vbTextCompare
Set objUser = GetObject("WinNT://" _
& strDomain & "/" _
& strUserName & ",user")
For Each objGroup In objUser.Groups
CreateMemberOfObject.Add objGroup.Name, "-"
Next
Set objUser = Nothing
End Function