in reply to How can I get which Windows domain an IP belongs to?
Maybe this can help.
Or, as previously suggested, capture the output of nbtstat and keep only the <00> GROUP entry.