📄 ispdc.vbs
字号:
'ISPDC.VBS
'checks if computer is a Primary Domain Controller (PDC)
Dim objWMIObject, objServices, objNetwork, nF, bFound, objRole
Set objNetwork = CreateObject("WScript.Network")
'get an instance of the Win32_ComputerSystem for the local computer
Set objWMIObject = _
GetObject("winmgmts:{impersonationLevel=impersonate}" & _
"!Win32_ComputerSystem='" & objNetwork.ComputerName & "'")
bFound = False
'check if Roles property is Empty array
If Not IsNull(objWMIObject.roles) Then
'loop through roles array and check if it contains any occurrence
'of Primary_Domain_Controller
For Each objRole In objWMIObject.Roles
If objRole = "Primary_Domain_Controller" Then
bFound = True
Exit For
End If
Next
End If
'if PDC then return -1, otherwise 0
If bFound Then WScript.Quit -1
WScript.Quit 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -