Returns the basic role (domain controller, member server, workstation, etc.) for a computer.
strComputer = "."Set objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colComputers = objWMIService.ExecQuery _("Select DomainRole from Win32_ComputerSystem")For Each objComputer in colComputersSelect Case objComputer.DomainRoleCase 0strComputerRole = "Standalone Workstation"Case 1strComputerRole = "Member Workstation"Case 2strComputerRole = "Standalone Server"Case 3strComputerRole = "Member Server"Case 4strComputerRole = "Backup Domain Controller"Case 5strComputerRole = "Primary Domain Controller"End SelectWscript.Echo strComputerRoleNext
This is a VB Script, this can be used by saving the file in .vbs file