For logon scripts. Basic check – doesn't take nested groups into account.
Option Explicit
Dim objNetwork
Set objNetwork = CreateObject("WScript.Network")
Function IsInGroup(sGroup)
Dim objGroupDict, objGroup, objUser
IsInGroup = false
Set objGroupDict = CreateObject("Scripting.Dictionary")
objGroupDict.CompareMode = vbTextCompare
Set objUser = GetObject("WinNT://" & objNetwork.UserDomain & "/" & objNetwork.UserName & ",user")
For Each objGroup In objUser.Groups
If objGroup.Name = sGroup Then
IsInGroup = true
End If
Next
End Function
'---------------------------------------
' Usage
'---------------------------------------
If IsInGroup("Printer Users") Then
objNetwork.AddWindowsPrinterConnection "\\servername\printername"
objNetwork.SetDefaultPrinter "\\servername\printername"
End If