-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAD Enum Ping.vbs
More file actions
31 lines (30 loc) · 1.24 KB
/
Copy pathAD Enum Ping.vbs
File metadata and controls
31 lines (30 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'Example Script that pings every machine listed in an AD container
'
'Written by Shawn Stugart
'========================================================================
Const ADS_SCOPE_SUBTREE = 2
set objShell = CreateObject("WScript.Shell")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name from 'LDAP://CN=Computers,DC=domain100,DC=internal' " _
& "where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
strCompName = objRecordSet.Fields("Name")
Set objScriptExec = objShell.Exec("ping -n 1 -w 1000 " & strCompName)
strPingStdOut = Lcase(objScriptExec.StdOut.ReadAll)
If InStr(strPingStdOut, "reply from ") Then
WScript.Echo strCompName & " is responding."
Else
WScript.Echo strCompName & " is NOT responding."
End If
objRecordSet.MoveNext
Loop