http://dieseyer.de • all rights reserved • © 2011 v11.4

'*** v8.1 *** www.dieseyer.de *******************************
'
' Datei: computer-function.vbs
' Autor: dieseyer@gmx.de
' Auf: www.dieseyer.de
'
' Microsoft: The Portable Script Center - v3.0, Nov. 2004
' "Verify Computer Role"
'
'************************************************************

Option Explicit

Dim strComputer

strComputer = WScript.CreateObject("WScript.Network").ComputerName

MsgBox " """ & strComputer & """ ist" & vbCRLF & vbCRLF & ComputerFu( strComputer ), , WScript.ScriptName

WScript.Quit

'*** v8.1 *** www.dieseyer.de ****************************
Function ComputerFu( PCname )
'*********************************************************
Dim objWMIService : Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & PCname & "\root\cimv2")
Dim colComputers : Set colComputers = objWMIService.ExecQuery("Select DomainRole from Win32_ComputerSystem")
Dim objComputer
Dim strComputerRoleTxt
For Each objComputer in colComputers
Select Case objComputer.DomainRole
Case 0
strComputerRoleTxt = "Standalone Workstation"
Case 1
strComputerRoleTxt = "Member Workstation"
Case 2
strComputerRoleTxt = "Standalone Server"
Case 3
strComputerRoleTxt = "Member Server"
Case 4
strComputerRoleTxt = "Backup Domain Controller"
Case 5
strComputerRoleTxt = "Primary Domain Controller"
End Select
ComputerFu = objComputer.DomainRole
Next

ComputerFu = ComputerFu & ": " & strComputerRoleTxt

End Function ' ComputerFu( PCname )

http://dieseyer.de • all rights reserved • © 2011 v11.4