;; 
;;=====================================================================================----- 
;; 
;;FUNCTION       PartOfDomain() 
;; 
;;ACTION         Determines if the local computer is a member of a domain or workgroup 
;; 
;;AUTHOR         Glenn Barnas 
;; 
;;VERSION        1.0  - 2015/04/08 
;; 
;;HISTORY        1.0  - 2015/04/08 - Initial Release 
;; 
;;SYNTAX         PartOfDomain() 
;; 
;;PARAMETERS     None 
;; 
;;REMARKS        Returns null if unable to query WMI 
;; 
;;RETURNS        True if a domain member, false otherwise 
;; 
;;DEPENDENCIES   WMI 
;; 
;;TESTED WITH    W2K3, W2K8, W2K12 
;; 
;;EXAMPLES        
; 
Function PartOfDomain()
 
  Dim $_objWMISvc				; WMI service object 
  Dim $_ColItems				; collection of WMI items 
  Dim $_objItem					; enum item for collection 
 
  $PartOfDomain = ''
 
  $_objWMISvc = GetObject('winmgmts:\\.\root\cimv2')
  If @ERROR Exit 1 EndIf
  $_colItems  = $_objWMISvc.ExecQuery('Select * from Win32_ComputerSystem', , 48 )
  For Each $_objItem in $_colItems
    If $_objItem.PartOfDomain
      $PartOfDomain = 1
    Else
      $PartOfDomain = 0
    EndIf
  Next
 
  Exit 0
 
EndFunction