Local Admins

List local administrators across a network domain.


' 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
      '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
      End If

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
            Wscript.Echo strComputer & " is NOT available"
            PcOnline = True
            Wscript.Echo strComputer & " is responding to a ping"
          End If
    Set objPing=Nothing
    Set objStatus=Nothing
End Function

“A good reputation is more valuable than money” ~ Publilius Syrus


userinfo.vbs - List User properties (as shown in ADUC)

© Copyright SS64.com 1999-2015
Some rights reserved