Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Windows 2008R2 last successful backup

$
0
0

I have a system monitoring system that expects to see a singly code returned to it when it runs a script. The code I'm looking for is the number of days since last successful backup. The even id is 4 in the "Microsoft-Windiws-Backup" event log. I don't want the event log contents to be included in the output so I direct that to a CSV file. I'm having trouble getting the "days since last successful backup" to write to host. I'm pulling my hair out at this point.

Any ideas?

$t = [DateTime]::Now.AddDays(1)

Get-WinEvent 'Microsoft-Windows-Backup' |
Where-Object{$_.ID -eq "4"} |

Select-Object ID,TimeCreated |
export-csv C:\"program files"\"Zabbix Agent"\AA.csv -NoType
$span = (($t) - $timecreated).Days
Write-Host $span

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles