Checking For A Database Backup with PowerShell

Todays PowerShell Box of Tricks Post is about backups

I highly recommend you go and read bookmark and come straight back Stuart Moore’s series on Backups with Powershell The link takes you to the category showing all of the posts in the series

Whilst I have many other methods to inform me if backups fail, sometimes someone walks up to the desk ignores the headphones in my ears (They are bright yellow FFS), eyes fixed on the screen, face deep in concentration and asks me a question. It was for times like these that the functions from this series were written.

“When was this database last backed up?”

Auditors, managers, bosses, developers all can come and ask this question. I just turn to my PowerShell prompt type


and show him the screen. Job done (Sometimes)

As I mentioned previously there are 154 properties on the database object. Three of them are


We simply call these and if the date reported is ’01 January 0001 00:00:00′ print NEVER

The Code is here

One thought on “Checking For A Database Backup with PowerShell

  1. Pingback: Show The Last Backups On A Server with PowerShell | SQL DBA with A Beard

Please feel free to comment on this post. All comments are moderated first before appearing on the site

This site uses Akismet to reduce spam. Learn how your comment data is processed.