' Listing 13: The getDomainRole Function Private Function getDomainRole(ByVal strComputer) Dim objWMIService, colItems, objItem, strRole Set objWMIService = GetObject("winmgmts:\\"& strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem") On Error Resume Next For Each objItem In colItems Select Case (objItem.DomainRole) Case 0 strRole = "Standalone Workstation" Case 1 strRole = "Member Workstation" Case 2 strRole = "Standalone Server" Case 3 strRole = "Member Server" Case 4 strRole = "Backup DC" Case 5 strRole = "Primary DC" End Select Next getDomainRole = strRole Err.Clear On Error Goto 0 Set objWMIService = Nothing: Set colItems = Nothing End Function