VBScript判断机器的角色

下面这个脚本用于判断机器在域里面的角色:

' use "." for local computer



sComputer = "." 

WScript.Echo DomainRole(sComputer)



Function DomainRole(sNode)

Set oWMI = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & sNode & "\root\cimv2")

Set colComputer = oWMI.ExecQuery("Select DomainRole from Win32_ComputerSystem")

For Each oComputer in colComputer

     iDR = oComputer.DomainRole

Next



Select Case iDR

Case 0

    DomainRole = "Standalone Workstation"

Case 1

    DomainRole = "Member Workstation"

Case 2

    DomainRole = "Standalone Server"

Case 3

    DomainRole = "Member Server"

Case 4

    DomainRole = "Backup Domain Controller"

Case 5

    DomainRole = "Primary Domain Controller"

Case Else

    DomainRole = "Unknown"

End Select



End Function

你可能感兴趣的:(VBScript)