On Error Resume Next Dim objFS, objFileOut Dim strOutputFile dim objPing dim objStatus dim strComputer dim objRS Set WshNetwork = WScript.CreateObject("WScript.Network") ' generate a filename base on the script name strOutputFile = "./" & WshNetwork.UserDomain & " Domain Server List" & ".csv" Set objFS = CreateObject("Scripting.fileSystemObject") Set objFileOut = objFS.CreateTextFile(strOutputFile, TRUE) 'Put stuff in here to get strComputer and do the loop for all the services. strActiveDirectoryDomainDNSName = WshNetwork.UserDomain strBase = ";" strFilter = "(&(objectclass=computer)(objectcategory=computer)" & "(operatingSystem=*Server*));" strAttrs = "cn;" strScope = "subtree" set objConn = CreateObject("ADODB.Connection") objConn.Provider = "ADsDSOObject" objConn.Open "Active Directory Provider" Set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope) objFileOut.WriteLine "Server Accounts in Active Directory" objFileOut.WriteLine " " objFileOut.WriteLine "Online servers will respond with Hello" objFileOut.WriteLine "Offline servers will respond with No Answer" objFileOut.WriteLine "Verify Online servers with the Backup list" objFileOut.WriteLine "Ask Primary if Offline systems should have their account removed from AD" objFileOut.WriteLine " " Set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope) objRS.MoveFirst while Not objRS.EOF strComputer = lcase(objRS.Fields(0).Value) 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 objFileOut.WriteLine strComputer & "," & "No Answer" Else objFileOut.WriteLine strComputer & "," & "Hello" End If Next objRS.MoveNext wend objFileOut.Close Set objFileOut = Nothing Set objFS = Nothing Set objPing=Nothing Set objStatus=Nothing WScript.Echo "The Script has Completed." WScript.Quit(0)