' Installs network printer and sets default ' Created: 03/03/2013, By: Michael Tabor Option Explicit On Error Resume Next Dim objNetwork, objSysInfo, objUser, strGroup ' Initialize constants with Group names ' AD groups should follow this convention: ' "!Group###name" entered here in all CAPS Const Kentucky = "cn=!KY_Insurance" Const Ohio = "cn=!OH_Iurance" ' Create objects and extract strGroup values Set objNetwork = CreateObject("WScript.Network") Set objSysInfo = CreateObject("ADSystemInfo") Set objUser = GetObject("LDAP://" & objSysInfo.UserName) ' Groups are polled and listed in an array. If only 1 ' non-builtin group exists, the 1st line errors and ' the 2nd line will hold the value strGroup = UCase(Join(objUser.MemberOf)) strGroup = UCase(objUser.MemberOf)) ' If logic testing strGroup for the values in Const groups If InStr(strGroup, UCASE(Kentucky)) Then objNetwork.AddWindowsPrinterConnection ' Adds printer "\\kentucky-print-server\ky-ins-printer" ' Printer network location objNetwork.SetDefaultPrinter ' Sets default printer "\\kentucky-print-server\ky-ins-printer" ElseIf InStr(strGroup, UCASE(Ohio)) Then objNetwork.AddWindowsPrinterConnection "\\ohio-print-server\oh-ins-printer" objNetwork.AddWindowsPrinterConnection "\\ohio-print-server\oh-office-printer" objNetwork.SetDefaultPrinter "\\ohio-print-server\oh-ins-printer" End If Set objNetwork = Nothing Set objSysInfo = Nothing Set objUser = Nothing WScript.Quit