'Script to Seperate the reachable computers from the list of computers in the file given as input. '================================================================================================== Set objArgs = WScript.Arguments If WScript.Arguments.Count < 1 Then Wscript.Echo "" Wscript.Echo " SYNTAX to use the GetReachablecomputer Script" Wscript.Echo "" Wscript.Echo " Syntax : GetReachablecomputer.vbs " Wscript.Echo Wscript.Echo " Example : GetReachablecomputer.vbs DC_SoM_Failed_List.txt " Wscript.Echo "" Wscript.Echo " Note : The output would be available in .txt files in the same directory" Wscript.Quit End If Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.GetFile(objArgs(0)) Set objOutFile1 = objFSO.OpenTextFile("Reachable_Computers.txt", 2, True) Set objOutFile2 = objFSO.OpenTextFile("UnReachable_Computers.txt", 2, True) If objFile.Size > 0 Then Set objReadFile = objFSO.OpenTextFile(objArgs(0), 1) Do Until objReadFile.AtEndOfStream strMachines = objReadFile.Readline Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._ ExecQuery("select * from Win32_PingStatus where address = '"_ & strMachines & "'") For Each objStatus in objPing If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then WScript.Echo("Computer " & strMachines & " is not reachable") objOutFile2.WriteLine strMachines else objOutFile1.WriteLine strMachines End If Next Loop objReadFile.Close Wscript.Echo Wscript.Echo " Note : The output of filtered reachable computers are redirected to Reachable_Computer.txt file " Wscript.Echo " and Failed computers to UnReachable_Computers. " Wscript.Echo Wscript.Echo " Note : You can use it with PSEXEC tool for Firewall Exceptions, Desktop Central Agent installation etc.," Wscript.Echo Wscript.Echo " Syntax for PSEXEC : For /f %f in do PSEXEC.exe \\%f -u mydomain\administrator " Wscript.Echo " -p mydomain_password CSCRIPT \\\Configurator.vbs " Else Wscript.Echo "The file is empty." End If