# encoding: utf-8 # api: powershell # title: Show Last DB Backup # description: ############################################################################################# # version: 0.1 # type: function # author: SQLDBAwithabeard # license: CC0 # function: Show-LastDatabaseBackup # x-poshcode-id: 4462 # x-archived: 2013-09-17T23:56:17 # x-published: 2013-09-11T18:39:00 # # # # NAME: Show-LastDatabaseBackup.ps1 # AUTHOR: Rob Sewell http://sqldbawithabeard.com # DATE:06/08/2013 # # # COMMENTS: Load function for Showing Last Backup of a database on a server # ############################################################################################# # # NAME: Show-LastDatabaseBackup.ps1 # AUTHOR: Rob Sewell http://sqldbawithabeard.com # DATE:06/08/2013 # # COMMENTS: Load function for Showing Last Backup of a database on a server # ———————————————————————— Function Show-LastDatabaseBackup ($SQLServer, $database) { $server = new-object "Microsoft.SqlServer.Management.Smo.Server" $SQLServer $db = $server.Databases[$database] Write-Host "Last Full Backup" $LastFull = $db.LastBackupDate if($lastfull -eq '01 January 0001 00:00:00') {$LastFull = 'NEVER'} Write-Host $LastFull Write-Host "Last Diff Backup" $LastDiff = $db.LastDifferentialBackupDate if($lastdiff -eq '01 January 0001 00:00:00') {$Lastdiff = 'NEVER'} Write-Host $Lastdiff Write-Host "Last Log Backup" $lastLog = $db.LastLogBackupDate if($lastlog -eq '01 January 0001 00:00:00') {$Lastlog= 'NEVER'} Write-Host $lastlog }