List local administrators across a network domain.
'localadmins.vbs
' Usage:
' cscript //Nologo localadmins.vbs
' List local administrators across a network domain
Dim oDomain, strComputer,oLocalGroup,Item,IsOnline
' Enumerate all the computers in the domain (OU specified below)
Set oDomain = GetObject ("LDAP://cn=Computers,DC=ss64,DC=com")
For Each strComputer in oDomain
Wscript.Echo strComputer.CN
'Check if the PC is booted and online
IsOnline=PcOnline(strComputer.CN)
'If so then list the local Administrators
If IsOnline = true Then
Set oLocalGroup = GetObject("WinNT://" & strComputer.CN & "/Administrators,group")
For Each item In oLocalGroup.Members
Wscript.Echo strComputer.CN & " " & item.ADsPath
Next
End If
Next
Function PcOnline (strComputer)
'Check if the remote machine is online.
Dim objPing,objStatus
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select Replysize from Win32_PingStatus where address = '" & strComputer & "'")
For Each objStatus in objPing
If IsNull(objStatus.ReplySize) Then
PcOnline=False
Wscript.Echo strComputer & " is NOT available"
Else
PcOnline = True
Wscript.Echo strComputer & " is responding to a ping"
End If
Next
Set objPing=Nothing
Set objStatus=Nothing
End Function
“A good reputation is more valuable than money” ~ Publilius Syrus
Related:
userinfo.vbs - List User properties (as shown in ADUC)