PoshCode Archive  Artifact Content

Artifact e4cbbf2c0a62d7b913e23adfdadb3bd0bcc50ad4c0073a234e5a86a764d7b030:

  • File Show-Last-DB-Backup.ps1 — part of check-in [e3ef9c3fcf] at 2018-06-10 13:41:19 on branch trunk — ############################################################################################# (user: SQLDBAwithabeard size: 1721)

# 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

}