Append results of a variable to text

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Daniel Krebs Daniel Krebs 5 months, 4 weeks ago.

  • Author
    Posts
  • #63012
    Profile photo of Will M
    Will M
    Participant

    Hi folks,

    I'm sure this is an easy thing to sort out..

    So here is a sample of my code:

    #Query the dashboard on netapp filer and return result
    $gather_dashboard =
    {
    write-host "* Alarm Dashboard *"
    (Get-NcDashboardAlarm | format-table -AutoSize)
    }
    "`n"

    #run the gather variables and output to output.txt
    $today = Get-Date
    $dir = "$data_dir_date\output.txt"
    Add-content $dir "Netapp health Checks for $filer1, $today"
    *****here i want to write the output of $gather_dashboard into the text file $dir, then create a new line in text file and do the same thing with a different variable*****

    SO what i am trying to achieve is a log of the ouput of each variable of which there are 6 or 7. There would have to be 3 lines between each output, and each output has a relevant title inserted.

    Currently anything i do overwrites the text file with each variable or just produces nothing.

    What do I need to do?

  • #63016
    Profile photo of Daniel Krebs
    Daniel Krebs
    Moderator

    Please try below:

    $today = Get-Date
    $dir = "$data_dir_date\output.txt"
    "Netapp health Checks for $filer1, $today" | Out-File -FilePath $dir -Append
    

You must be logged in to reply to this topic.