A small KiX-version could be

Code:
Break On

$Dom = @LDomain
$usr = 'Guest'

$oWMIService = GetObject("winmgmts:root\cimv2")
$cItems = $oWMIService.ExecQuery("Select * from Win32_Group where LocalAccount = 0 And Name = 'domain users'")
For Each $oItem In $cItems
$SID = $oItem.SID
Next

$SID = Left($SID,InStrRev($SID,'-')) ; Get Domain RID
$oUser = GetObject("WinNT://" + $Dom + "/"+ $usr + ",User")
$SID = $SID + $oUser.Get("primaryGroupID")

? 'Primary group name = ' + SidToName($SID)

Get $x



-Erik