complete vbs script... i get no results in either the ping or no ping files
-----------------------------------------------
'========
'= Main =
'========
Dim Computer, elem
PingSystems
MakeArray
MsgBox "Listing Local Admins is now complete"
'================
'= Ping Systems =
'================
Sub PingSystems()
Dim Outputfile, FSO, OFile, Outputfile2, oFile2
Dim iFile, objContainer, StdOut, objShell
OutputFile="C:\share\ad\pingSuccessful.txt"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set oFile = FSO.CreateTextFile(OutputFile, True)
OutputFile2="C:\share\ad\pingFailed.txt"
Set oFile2 = FSO.CreateTextFile(OutputFile2, True)
InputFile="c:\share\ad\container.txt" 'contains OU structure
Set iFile = FSO.OpenTextFile(InputFile, 1, true) 'assume existing else create an empty file
WScript.Echo "Pinging Systems Now..."
Do until iFile.AtEndOfStream
strComputerContainer = iFile.ReadLine
Set objContainer = GetObject("LDAP://" & strComputerContainer)
objContainer.Filter = Array("Computer")
Set StdOut = WScript.StdOut
Set objShell = CreateObject("WScript.Shell")
On Error Resume Next
For Each objComputer In objContainer
Computer = Split(objComputer.Name, "=")(1)
Set objScriptExec = objShell.Exec("ping -n 2 -w 1000 " & Computer)
do while objScriptExec.status=0
wscript.sleep 100
loop
strPingResults = LCase(objScriptExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from")<>0 Then
oFile.WriteLine(Computer)
Else
oFile2.WriteLine(Computer)
End If
Next
Loop
iFile.close
oFile2.close
oFile.close
WScript.Echo "Pinging Systems Complete!"
End Sub
'========================
'= Opens TXT into array =
'========================
Sub MakeArray
Const ForReading = 1
Const WKS = "c:\share\ad\pingsuccessful.txt"
Dim fso, f
Dim arrText()
Dim text
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fs

penTextFile(WKS, ForReading)
iUpperBound = 0
While Not f.AtEndOfStream
ReDim Preserve arrText(iUpperBound)
arrText(UBound(arrText)) = f.ReadLine
iUpperBound = iUpperBound + 1
Computer = arrText(UBound(arrText))
WScript.Echo Computer
if not isempty(Computer) then
GetLocalAdmins Computer 'calls sub to get local admin info - pass computer as variable explicitly
end if
Wend
f.Close
End Sub
'=====================
'= Gets Local Admins =
'=====================
Sub GetLocalAdmins (Computer)
Dim objComp
strComputer = Computer
Set objComp = GetObject("WinNT://" & strComputer) 'seems to have issues here.
objComp.GetInfo 'or here....
If objComp.PropertyCount > 0 Then
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
If objGroup.PropertyCount > 0 Then
WScript.Echo "The members of the local Administrators group on " & strComputer & " are:"
For Each mem In objGroup.Members
WScript.echo vbTab & Right(mem.adsPath,Len(mem.adsPath) - 8)
Next
Else
WScript.echo "** Connecting to the local Administrators group on " & strComputer & " failed."
WScript.Quit 1
End If
Else
WScript.Echo "** Connecting to " & strComputer & " failed."
WScript.Quit 1
End If
End Sub