Powershell backup log to csv

powershellwindows-server-2008-r2

Hi I have learned a short command to create a CSV from the backup log on my server. I have 5 of them and I wonder if there is a way to show their result in a website format on one pages.
The whole aim is to collect various CSV files so I can have a general Server Health Check page that would tell me what I need e.g.:

  • Backup state
  • Computer last logon
  • Server uptime
  • Disk usage etc.

I can fit those on a webpage that is not an issue but…

Whit the Backup:

the command picks a computer's event log and puts the backup in a csv so I can do anything with it in PHP for example or later migrate to SQL or something.

$events = get-winevent -logname Microsoft-Windows-Backup |export-csv -path C:\inetpub\wwwroot\backup.csv

As I have done the first test I realised:

  • it is not as sophisticated as I though I have all the details but: the status is either stop or start so no Done the job command…
    When you look at the Windows Backup Solution that is easy to read that the task completed or failed. On the event log that is not that simple.

  • the drives are not readable formats if you look at the eventlog there is no C or D drive just codes instead

see below:

Information Stop The system state recovery operation has completed.

Information Info The system state recovery operation that started at '?2013?-?02?-?17T22:43:58.000000000Z' has completed successfully. Log of the files successfully recovered: 'C:\Windows\Logs\WindowsServerBackup\SystemStateRestore-17-02-2013_22-43-58.log'.

Information Stop The backup set of volume '{FFC838C7-793E-11E2-B603-806E6F6E6963}' on the backup storage location has been loaded.

Information Stop The backup set of volume '{FFC838C6-793E-11E2-B603-806E6F6E6963}' on the backup storage location has been loaded.

Information Start The system state recovery operation started at '?2013?-?02?-?17T22:43:58.000000000Z'.

Information Stop The backup operation has completed.

Information Info The backup operation has finished successfully.

Information Start The backup operation has started.

If someone could contribute some better option I would really appreciate. I only just started powershell so I am still learning. Any comment would be great as I am happy to learn.

Best Answer

Short version... use get-wbsummary from PS instead and pipe that to a file.

Long Version... I am actually doing something similar. I have a centralized script to do backup and it kicks off wbadmin jobs as part of a script. At about 10am the next morning, I have a backup "checker" that runs on each server. It uses the PS command "get-wbsummary" and dumps that data to a txt file. It then parses that txt file to get the "LastSuccessfulBackupTime" and "LastBackupTime" and compares them. It also does a quick size compare between the disks and the backup VHDs (its never the same and if its close I leave it be). It then takes all the information, and emails me the resulting information. While this is actually in VBS, it very likely could be done more easily in PS completely. I tried going the event log route too, but found there wasn't nearly enough information in there to get me what I needed.