Script to ping multiple hosts and return domain info to a txt or csv file

Hi,
I wonder if anyone can help.  I need a script that will allow me to ping multiple hosts (all listed on seperate lines in a txt file) and return IP, server up\down and domain info to a txt or ideally a csv file.
I'm sure this must have been done\requested before but I can't seem to find the correct script anywhere
Thanks for your help
Mal

Try this modification:
$result=@()
Get-Content p:\list.TXT | %{
$start_name = $_
$conn = Test-Connection -ComputerName $_ -Quiet
if(-not $conn)
$start_name = ""
Try
$dns = [System.Net.Dns]::GetHostEntry($_)
$dns_host = $dns.HostName
$dns_ip = $dns.AddressList | select -ExpandProperty IPAddressToString
catch
$dns_host = "invalid host name" #as jrich proposed :)
$dns_ip = "invalid host name" #as jrich proposed :)
$start_name = ""
$HostObj = New-Object PSObject -Property @{
Host = $start_name
IP = $dns_ip
DNSHost = $dns_host
Active = $conn
$result += $HostObj
$result | Export-Csv p:list.csv -NoTypeInformation

Similar Messages

  • How do setup multiple send and receive domain on single virtual ironport?

    HI all
    how do i setup multiple send and receive domain on single virtual ironport?
    Daemien

    Please use the admin guide to assist you for setup/configuration:
    http://www.cisco.com/c/dam/en/us/td/docs/security/esa/esa8-0/user_guide/ESA_8-0-1_User_Guide.pdf
    On the VESA - the Recipient Access Table (RAT) will control which domains your appliance accepts for.  
    AsyncOS uses a Recipient Access Table (RAT) for each public listener to manage accept and reject actions for recipient addresses. Recipent addresses include these:
    •Domains
    •Email addresses
    •Groups of email addresses
    This is covered in detail in the "Overview of Accepting or Rejecting Connections Based on the Recipient’s Address" section.
    Please see the "Configuring the Gateway to Receive Email" section for configuration of appliance for domains.
    Please see the "Defining Which Hosts Are Allowed to Connect Using the Host Access Table (HAT)" section for configuration of appliance for sending.
    I hope this helps!
    -Robert
    (*If you have received the answer to your original question, and found this helpful/correct - please mark the question as answered, and be sure to leave a rating to reflect!)

  • Batch script to open multiple excel and doc files

    Hi Everyone,
    Could anybody please provide a batch script to open multiple excel and doc files at a time.
    Appreciate ur quick response.
    Regards,

    You have several scripting choices within Windows. At a basic level you've got "batch files" - which run a series of command interpreter commands, and have a file extension of .BAT or .CMD. If you just wanted to open a list of Word documents, then assuming that the path to Word is correct (something like this below) you could list these in a file with a .BAT extension and run this (e.g. double click on it):
    "C:\Program Files\Microsoft Office\Office\Winword.exe" "C:\Documents and Settings\All Users\Desktop\File1.DOC"
    "C:\Program Files\Microsoft Office\Office\Winword.exe" "C:\Documents and Settings\All Users\Desktop\File2.DOC"
    "C:\Program Files\Microsoft Office\Office\Winword.exe" "C:\Documents and Settings\All Users\Desktop\File3.DOC"
    "C:\Program Files\Microsoft Office\Office\Excel.exe" "C:\Documents and Settings\All Users\Desktop\File1.XLS"
    "C:\Program Files\Microsoft Office\Office\Excel.exe" "C:\Documents and Settings\All Users\Desktop\File2.XLS"
    Another script language is VBScript, which was the example I gave. VBScript is available on most Windows platforms and can be run from a command prompt or within Windows. If you save the text I gave you above to a file with a .VBS extension you can double-click to run it (Windows) or open a command prompt and type CSCRIPT MyVBScript.VBS (assuming that's the name of the your .VBS file).
    Other script languages are available to achieve the same thing, including Powershell, however you'd need to have Powershell available on your PC.

  • I have a request from a customer to run a script to create multiple Usernames and Passwords on ACS5.3 appliance.

    I have a request from a cutomer to run a script to create multiple username and password on ACS5.3 Appliance. Does anyone has any suggestion on how to go about this?

    Have you tried using the import option on the ACS? You can put all your accounts in a csv file and upload it into the ASA.
    http://www.cisco.com/en/US/docs/net_mgmt/cisco_secure_access_control_system/5.3/user/guide/users_id_stores.html#wp1132152
    If that doesnt work you can use the REST Web Services in ACS also:
    http://www.cisco.com/en/US/docs/net_mgmt/cisco_secure_access_control_system/5.3/sdk/rest.html
    Thanks,
    Tarik Admani
    *Please rate helpful posts*

  • How to search a special string in txt file and return it's position in txt file?

    How to search a special string in txt file and return it's position in txt file?

    I just posted a solution for a similar question here:  http://forums.ni.com/ni/board/message?board.id=170​&view=by_date_ascending&message.id=362699#M362699
    The top portion can search for the location of a string, while the bottom portion is to locate the position of a character.  Both can search for a character.
    The position of the character within the file is displayed in the indicator(s).
    R

  • Explain the Batch script to ping multiple computers

    Hello,
    Please comment and explain each liner of the script.
    @echo off
    if exist d:\tools\computers.txt goto Label1
    echo.
    echo Cannot find d:\tools\computers.txt
    echo.
    Pause
    goto :eof
    :Label1
    echo PingTest executed on %date% at %time% > d:\tools\z.txt
    echo ================================================= >> d:\tools\z.txt
    for /f %%i in (d:\tools\computers.txt do call :Sub %%i
    notepad d:\tools\z.txt
    goto :eof
    :Sub
    echo Testing %1
    set state=alive
    ping -n 1 %1 | find /i "bytes=" || set state=dead
    echo %1 is %state% >> d:\tools\z.txt

    @echo off
    Don't echo these batch file commands to the screen. Using the @ sign means including the current line.
    if exist d:\tools\computers.txt goto Label1
    If there is a file called d:\tools\computers.txt then jump to the section of the batch file called :Label1
    echo.
    Type a dot to the screen.
    echo Cannot find d:\tools\computers.txt
    As the file called  d:\tools\computers.txt  was not found then type "Cannot find Etc." to the screen. This file must exist in the location specified. It presumably contains a list of machine names or IP addresses; one per line.
    Pause
    Put a prompt on the screen which says "Press any key to continue..." and then wait until a key is pressed.
    goto :eof
    Go to the end of the batch file (i.e. terminate)
    :Label1
    Now there is a subsection called Label
    echo PingTest executed on %date% at %time% > d:\tools\z.txt
    Type the words "PingTest executed on " along with the current date and time " but instead of typing them to the screen, pass them (using the > symbol) to a file called d:\tools\z.txt
    for /f %%i in (d:\tools\computers.txt do call :Sub %%i
    There's actually a bracket missing from this, so the correct line should read:
    for /f %%i in (d:\tools\computers.txt) do call :Sub %%i
    Loop through each line of the file d:\tools\computers.txt which presumably contains a list of machine names or IP addresses. Call a subroutine called :Sub passing it the line that's just been read. For example this file might look like:
        193.1.1.1
        193.1.1.2
        193.1.1.200
    notepad d:\tools\z.txt
    The file d:\tools\z.txt is a log produced by the batch file. This line will launch NotePad with this file so you can view it.
    goto :eof
    Go to the end of the batch file (i.e. terminate)
    :Sub
    This is the subsection call Sub which gets called by the For loop.
    echo Testing %1
    Type to the screen the line that has been passed to this subsection. For example, "Testing 193.1.1.1"
    set state=alive
    Create a temporary value called "state" which is set to "alive"
    ping -n 1 %1 | find /i "bytes=" || set state=dead
    Call the PING executable. If you want to know more about this command then type PING /? from the command line. The output from this is then "piped" to the FIND executable which is set to ignore case (/i). Essentially it's looking for the PING command to be returning the text "bytes=" meaning that the IP address or machine name is responding to the ping. If the text is not found (so the find command failed) then the "state" value is changed from "alive" to "dead".
    echo %1 is %state% >> d:\tools\z.txt
    Type the IP address and the state value (dead or alive) to the file d:\tools\z.txt  . The presence of the two > characters means append rather than overwrite.
    There is some very clever batch file stuff in here, especially the use of the FOR command calling the subroutine and passing it a line at a time read from the text file, and then in the subroutine the use of the output piped from the PING command into the FIND command and then setting the state value if the find fails.
    Very underrated things batch files.

  • Multiple sites and personal domain

    Hi everyone!
    I'm having a problem with iWeb 08. Here's the details:
    Using iWebsite and iWeb '08 I've created 2 websites, one for personal use and one for my business.
    Now I'm interested in buying a personal domain for my business website.
    How can I do to set the personal domain only to my business site, leaving the personal one unchanged?
    Cheers,
    Samuele

    An easy way to manage multiple sites is either iWebSites or MultiSite.
    I use iWebSites to manage multiple sites.. It lets me create multiple sites and multiple domain files.
    If you have multiple sites in one domain file here's the workflow I used to split them into individual site files with iWebSites. Be sure to make a backup copy of your original Domain.sites files before starting the splitting process.
    This lets me edit several sites and only republish the one I want. Works for me.
    OT

  • How to restart an entire J2EE Cluster - With multiple hosts and instances

    I am looking for a definitive answer on the right way of Restarting an SAP Enterprise Portal CLUSTER without an ABAP stack.
    Currently the process is to use ssh into each box and either jcmon pf=<profile> then restart instance, or ssh into each host and run startsap/stopsap on each.
    Is there a better way?
    -Tim

    Hi,
    Please find the below SAP notes to understand the startup sequences.
    897933  Start and stop sequence for SAP systems
    936273  sapstartsrv for all platforms
    I would recommend you to check the below SAP link for more information.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60e24f7b-1ba1-2b10-c0a0-e514b855624b?quicklink=index&overridelayout=true
    Regards,
    Naveen.

  • Search for a word and return all the  lines (row) from the text file..

    Hi all,
    I need a help on how to search a string from the text file and returns all the lines (rows) where the searched string are found. I have included the code, it finds the indexof the string but it does not return the entire line. I would appreciate your any help.
    public class SearchWord
         public static void main(String[] args){
         //Search String
         String searchText = "man";
         //File to search (in same directory as .class file)
         String fileName = "C:\\Workspace\\MyFile.txt";
         //StringBuilder allows to create a string by concatinating
         //multiple strings efficiently.
         StringBuilder sb =
         new StringBuilder();
         try {
         //Create the buffered input stream, which reads
         //from a file input stream
         BufferedInputStream bIn =
         new BufferedInputStream(
         new FileInputStream(fileName));
         //Holds the position of the last byte we have read
         int pos = 0;
         //Holds #of available bytes in our stream
         //(which is the file)
         int avl = bIn.available();
         //Read as long as we have something
         while ( avl != 0 ) {
         //Holds the bytes which we read
         byte[] buffer = new byte[avl];
         //Read from the file to the buffer
         // starting from <pos>, <avl> bytes.
         bIn.read(buffer, pos, avl);
         //Update the last read byte position
         pos += avl;
         //Create a new string from byte[] we read
         String strTemp =
         new String(buffer);
         //Append the string to the string builder
         sb.append(strTemp);
         //Get the next available set of bytes
         avl = bIn.available();
         catch(IOException ex) {
         ex.printStackTrace();
         //Get the concatinated string from string builder
         String fileText = sb.toString();
         int indexVal = fileText.indexOf(searchText);
         //Displays the index location in the file for a given text.
         // -1 if not found
         if (indexVal == -1)
              System.out.println("No values found");
         else
              System.out.println("Search for: " + searchText);     }
    }

    Hi, you can use servlet class and use this method to get the whole line of searched string. You can override the HttpServlet to treat that class as servlet.
    public class ReportAction extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    //write your whole logic.
    BufferedReader br = new BufferedReader(new FileReader("your file name"));
    String line = "";
    while(line = br.readLine() != null) {
        if(line.contains("your search string")) {
            System.out.println("The whole line, row is :"+line);
    }

  • How to read and select only a specific lines from a CSV file. Pls help

    I have a java application to read a CSV file. I've already managed to read them all and output it to System.out.println(). Now the problem is I want to select a specific row of the records. How do I do it? Below is the codes i've typed.
    FileReader fr = new FileReader(fileName);
    BufferedReader inFile = new BufferedReader(fr);
    StringBuffer buf = new StringBuffer();
    String line = null;
    while ((line = inFile.readLine()) != null) {
    buf.append(line);
    buf.append("\n");
    String inString = buf.toString();
    System.out.println(inString);
    This is the record that i want to read. For example, I want to select n print out line "80,2.90,3.00,3.10,3.20,......."
    [Factor1]
    Time [s],0.00,0.10,0.20,0.30,0.40,0.50,0.60,0.70,0.80,0.90,1.00,1.10,1.20,1.30,1.40,1.50,1.60,1.70,1.80,1.90,2.00,2.10,2.20,2.30,2.40,2.50,2.60,2.70,2.80,2.90,3.00,3.10,3.20,3.30,3.40,3.50,3.60,3.70,3.80,3.90,4.00,4.10,4.20,4.30,4.40,4.50,4.60,4.70,4.80,4.90,5.00,5.10,5.20,5.30,5.40,5.50,5.60,5.70,5.80,5.90,6.00,6.10,6.20,6.30,6.40,6.50,6.60,6.70,6.80,6.90,7.00,7.10,7.20,7.30
    Phi-0 [dB],-0.86,-0.80,-0.80,-0.99,-0.56,-0.53,-0.95

    If you know how many bytes each line is, you can use RandomAccessFile to skip directly to the byte position corresponding to your desired line. Otherwise, you'll have to read each line and just ignore the ones you don't want.

  • .mac Hosting and Personal domain

    Any help?
    I bought a domain name from a registar in Greece and signed up for Google Apps.
    The @mydomain.co.gr woks with google mail and I want to keep it like this.
    Do I have to buy additional hosting services to be able to publish my site at .mac using www.mydomain.co.gr.
    Will my site be at web.mac.com or it must be hosted somewhere else an redirected to .mac?

    Chuck, you wrote that "all you should have to do is point the domain name to the .mac address." Can you please explain how? I have been on phone support and email contact with Apple and NOBODY knows how to do this! I kid you not. There are articles on How To but it doesn't work for me. My website does not publish to my personal domain name on iWeb and .mac, despite following the procedural instructions from Apple.
    At this point, my website is "published" to mac.com/myusername, but NOT to my personal domain name.
    Thanks for any suggestions you can give.
    Maria

  • How to pass a function with the same argument multiple times and return values in variables?

    The problem I have is I created a function which really is some kind of database.  Basically a bunch of:
    if (a.value == "this number"){
    b.value = "this expression";
    Inside the form are 2 dropdown lists that return numerical values which I want to process through that function and put the return value inside separate variables.
    var a = this.getField("OPE003.EVEN.1.MIP");
    Mip(a);
    var result1 = Mip();
    I tried to overwriting *a* to process the second field
    a = this.getField("OPE003.EVEN.2.MIP");
    Mip(a);
    var result2 = Mip();
    result1 and result2 are put in an array, joined as a string.
    Doing so, I always get the last processing twice as the final result.
    Can I use a function as a batch processing tool that way?

    You are right, I changed the code to what you said but how do I pass another value through my fonction so I can get Result1 and Result2?
    is it
    var a = this.getField("OPE003.EVEN.1.MIP");
    var b = this.getField("OPE003.EVEN.2.MIP");
    var result1 = Mip(a);
    var result2 = Mip(b);
    var c = new Array[result1, result2]

  • Dynamically run multiple VIs and return values

    Dear Experts:
    I would like to dynamically run 8 VIs from a main VI that esentially do the exact same thing.  The only thing that is different is the data passed to the VIs and the data returned.  The VI has a loop that can possible run for ever and each of the 8 loops can be started at different points in time.  I figure I would use a functional global to pass controls to the VI (loop).  I am not sure how I will get data from each loop.  I can't use a functional global for this because there is no sequencial timing. The number 8 might change so I can't just make 8 loops in main.
    I would like to be a little more clear.  How do you return individual data from a VI that has been dynamically launched 8 times at different points in time?

    The data type of the queue needs to be a cluster.  One element being an ID of some sort (this ID should be passed into the subVI) and another element being the actual data.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Case to query multiple values and return single value to different table

    Hi this is my first table:
    with Table_1
    as
          select 'CAR' Object, 2000 Policy    from dual
          union all
          select 'BIKE' Object, 2000 Policy  from dual
          union all
          select 'HOUSE' Object, 2000 Policy  from dual
          union all
          select 'MOBILE' Object, 2000 Policy  from dual
          union all
          select 'MONEY' Object, 2000 Policy  from dual
          union all
          select 'CREDIT' Object, 2000 Policy  from dual
          union all
          select 'SCOOTER' Object, 2001 Policy    from dual
          union all
          select 'BIKE' Object, 2001 Policy  from dual
          union all
          select 'BEACH' Object, 2001 Policy  from dual
          union all
          select 'HOUSE' Object, 2001 Policy  from dual
          union all
          select 'MONEY' Object, 2001 Policy  from dual
          union all
          select 'CREDIT' Object, 2001 Policy  from dual
          union all
          select 'DOOR' Object, 2002 Policy    from dual
          union all
          select 'BIKE' Object, 2002 Policy  from dual
          union all
          select 'GARDEN' Object, 2002 Policy  from dual
          union all
          select 'MOBILE' Object, 2002 Policy  from dual
          union all
          select 'MONEY' Object, 2002 Policy  from dual
          union all
          select 'CREDIT' Object, 2002 Policy  from dual
    select * from Table_1I need to Query the object column of table_1 for CAR or HOUSE and if they are present then returns 'Y' otherwise 'N'. This table_1 will link to table_2 via Policy and the result will be table_3
    with Table_2
    as
          select '21' AGE, 2000 Policy  from dual
          union all
          select '22' AGE, 2001 Policy from dual
          union all
          select '27' AGE, 2002 Policy from dual
    select * from Table_2
    with Table_3
    as
          select '21' AGE, 2000 Policy, 'Y'  Many_Obj    from dual
          union all
          select '22' AGE, 2001 Policy,  'Y' Many_Obj from dual
          union all
          select '27' AGE, 2002 Policy,  'N' Many_Obj from dual
    select * from Table_3Thanks in advance
    Banner:
    Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE 11.2.0.2.0 Production"
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    !

    Thanks for the insert statements.
    Here is one way
    with Table_1
    as
          select 'CAR' Object, 2000 Policy    from dual
          union all
          select 'BIKE' Object, 2000 Policy  from dual
          union all
          select 'HOUSE' Object, 2000 Policy  from dual
          union all
          select 'MOBILE' Object, 2000 Policy  from dual
          union all
          select 'MONEY' Object, 2000 Policy  from dual
          union all
          select 'CREDIT' Object, 2000 Policy  from dual
          union all
          select 'SCOOTER' Object, 2001 Policy    from dual
          union all
          select 'BIKE' Object, 2001 Policy  from dual
          union all
          select 'BEACH' Object, 2001 Policy  from dual
          union all
          select 'HOUSE' Object, 2001 Policy  from dual
          union all
          select 'MONEY' Object, 2001 Policy  from dual
          union all
          select 'CREDIT' Object, 2001 Policy  from dual
          union all
          select 'DOOR' Object, 2002 Policy    from dual
          union all
          select 'BIKE' Object, 2002 Policy  from dual
          union all
          select 'GARDEN' Object, 2002 Policy  from dual
          union all
          select 'MOBILE' Object, 2002 Policy  from dual
          union all
          select 'MONEY' Object, 2002 Policy  from dual
          union all
          select 'CREDIT' Object, 2002 Policy  from dual
    Table_2
    as
          select '21' AGE, 2000 Policy  from dual
          union all
          select '22' AGE, 2001 Policy from dual
          union all
          select '27' AGE, 2002 Policy from dual
    SELECT
         age,
         policy,
         Many_Obj
    from
    SELECT
         t2.age,
         t2.policy,
         CASE
              WHEN SUM(
                        CASE
                             WHEN t1.object IN ('CAR','HOUSE')
                             THEN 1
                             ELSE 0
                        END) over( PARTITION BY t2.age,t2.policy) > 0
              THEN 'Y'
              ELSE 'N'
         END Many_Obj,
         row_number() over (PARTITION BY t2.age,t2.policy order by 1) rn
    FROM
         Table_1 t1,
         Table_2 t2
    WHERE
         t1.policy = t2.policy
    where rn = 1;
    AGE POLICY                 MANY_OBJ
    21  2000                   Y       
    22  2001                   Y       
    27  2002                   N        I would advise you to spend some time learning analytic questions and using CASE expressions.

  • Combining multiple pdfs and then adding info to the blank fields.

    i combined multiple pdf's together to make one package.  The forms had text field in each of them, when i combined them i tried to add text to the blank spots and the info autofilled from page one on to all of the pages.  I do not want this to happen.  when i go to the tasks-> Forms-> Edit fields, it brings up each page with the text box and a number next to each one that page.  All of the pages have some numbers that are the same and i can not change them so the info does not fill in from info on other pages.  How do i stop this?

    Do you need the fields to remain interactive or need to extract the field data after you merge the document together?

Maybe you are looking for

  • Acrobat Pro 9.4.5 digital signing, menu gray but properties says allowed

    I have a document that had the signing menu gray/disabled. I tried going to Advanced->Security->Remove Security. The dialogue said "You Cannot change security on this document because the document enables extended features in Adobe Reader. You can sa

  • Making the background white

    Can someone help me make the background of my application white ? All it does is display a simple curve in a window. Here's the structure: public class Curve public static void main(String[] args) JFrame window = new JFrame(); CurvePane pane = new Cu

  • Cannot find javadoc. Make sure the documentation is mounted.

    Hi, I am getting the above message and not Java doc help page in the browser when I want to see help on String or File or JButton ! Pressing Alt+F1 or by menu neither works. Does anyone have idea what's went wrong since before this day I could use Ja

  • Elements 7 and Windows version 7

    Does anyone know if version 7 of Photoshop Elements will be compatible with the new Windows OS (7) when it comes out this fall? Mary Lou

  • Why are webpages narrow on Windows 7 with Firefox 6?

    Recently got a new PC that has Windows 7 installed. I downloaded Firefox as my browser. Version 6. All webpages are narrow and font size is small. Do no have this problem if I use IE. Is there a setting that I need to change in Firefox?