outputing and writing to a file

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Si Smith Si Smith 1 year, 2 months ago.

  • Author
  • #38077
    Profile photo of Si Smith
    Si Smith


    Im trying to write a script that is checking some info on servers then the idea is to output that to a file. I also want to add some text to that file in order for the reader to make sense of the data.

    for example

    Here is the text to understand the following output

    My OutPut (which works fine)
    nslookup $line | out-file $migrationcheckfile -append

    But now i want to put some text infront of that in the file. How do i do that?

    I tried adding
    Add-Content $migrationcheckfile "NSLOOKUP" infront of it but then the output command goes all onto one line and spaced out.

  • #38078
    Profile photo of Brian B
    Brian B

    "Whatever I want in the text file first" | out-file $migrationcheckfile -append
    nslookup $line | out-file $migrationcheckfile -append

  • #38079
    Profile photo of Si Smith
    Si Smith

    That's worked a treat. Thank you.

You must be logged in to reply to this topic.