Created
September 3, 2019 16:11
-
-
Save gbargsley/a654bfac66c1f6492fcefd953d5bfb77 to your computer and use it in GitHub Desktop.
LastBackup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $MyInstances = Get-DbaRegServer -SqlInstance cmsserver -Group "SDLC" | Sort-Object Name | |
| $today = get-date -Format "dd MMM yyyy" | |
| $style = " | |
| <style> | |
| TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse} | |
| TH{border-width: 1px;padding: 2px;border-style: solid;border-color: black;background-color:rgb(255, 255, 255);font-size:16;color:black} | |
| TD{border-width: 1px;padding: 5px;border-style: solid;border-color: black;color:black;font-size:14} | |
| </style> | |
| " | |
| $LastBackups = Get-DbaLastBackup -SqlInstance $MyInstances -ExcludeDatabase ReportServer, ReportServerTempDB, master, model, msdb, codarep_db, invrep_db, invrep_investor | |
| $LastBackupsSum = $LastBackups | Group-Object -Property Status -NoElement | convertTo-Html -Head $style -Property Name, Count | |
| $body = "<h2>Backup Status Summary:</h2>" | |
| $colorTagTable = @{'No Full or Diff Back Up in the last day' = ' bgcolor="#ff0000">No Full or Diff Back Up in the last day<'; | |
| 'No Log Back Up in the last hour' = ' bgcolor="#FFF703">No Log Back Up in the last hour<'; | |
| 'New database, not backed up yet' = ' bgcolor="#FFF703">New database, not backed up yet<'; | |
| 'OK' = ' bgcolor="#069619">OK<'} | |
| $colorTagTable.Keys | foreach { $LastBackupsSum = $LastBackupsSum -replace ">$_<",($colorTagTable.$_) } | |
| $body += $LastBackupsSum | |
| $body += "<br><br><hr><br><br>" | |
| $LastBackupsDetail = $LastBackups | convertTo-Html -Head $style -Property SqlInstance, Database, LastFullBackup, LastDiffBackup, LastLogBackup, Status | |
| $body += "<h2>Backup Status Detail:</h2>" | |
| $colorTagTable = @{'No Full or Diff Back Up in the last day' = ' bgcolor="#ff0000">No Full or Diff Back Up in the last day<'; | |
| 'No Log Back Up in the last hour' = ' bgcolor="#FFF703">No Log Back Up in the last hour<'; | |
| 'New database, not backed up yet' = ' bgcolor="#FFF703">New database, not backed up yet<'; | |
| 'OK' = ' bgcolor="#069619">OK<'} | |
| $colorTagTable.Keys | foreach { $LastBackupsDetail = $LastBackupsDetail -replace ">$_<",($colorTagTable.$_) } | |
| $body += $LastBackupsDetail | |
| $body > C:\Temp\BackupResults.html | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment