How can i export my Backup Event-Id's for 10 servers to 1 .txt file


  1. Posts : 6
    Windows 10
       #1

    How can i export my Backup Event-Id's for 10 servers to 1 .txt file


    Hi all!

    First of all, i am new to scripting but i want to learn it.
    We have Server 2012R2 in our organization and Windows Server Backup is running on each server daily. I want to automatically write a .txt file every day with the backup result to a destination (C:\Logfiles). I want all servers to write in that same file so i have 1 text-file with 10 server backup results from each one.

    I know i can attach a script to an Event-ID, such as eventid:4 (backup success).

    I am working on this for 2 days now but what am i doing wrong?
    I used powershell and also cmd but can't get it working (wevtutil qe Microsoft-Windows-Backup /f:text /q:"*[System/EventID=4] and *[EventData/Data[@Name='HRESULT']='0']")

    The script is needed for failed backup results and successfull backup results. I know that the failed backup results have a lot of event id's: 5,8,9,17,22 etc.

    Can somebody help me with this?
      My Computer


  2. Posts : 8,107
    windows 10
       #2

    Welcome to the forum. When wrting to a file you can use > to create the file ie dir >test.txt after that to write to same file you append with >> ie dir >>test.txt
      My Computer


  3. Posts : 6
    Windows 10
    Thread Starter
       #3

    Samuria said:
    Welcome to the forum. When wrting to a file you can use > to create the file ie dir >test.txt after that to write to same file you append with >> ie dir >>test.txt
    Thanks for that! Is there somebody who can help me with the correct syntax to get the event-id result for every day's backup?
      My Computer


  4. Posts : 6
    Windows 10
    Thread Starter
       #4

    I now used Backup Failed and Backup Success scripts with the following content: $text = "$(Get-Date) CC-server01: Backup failed" $text >> 'C:\Log\Logging.txt'

    Also for the one that is successfull.
    I did this on 2 servers for testing and i have one script for the mailing:

    Send-MailMessage -Attachments 'C:\Log\Logging.txt' -SmtpServer "mail.example.com" -From "backup@example.com" -To "user@example.com" -Subject "Daily Report"
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 13:17.
Find Us




Windows 10 Forums