Technical Article

PowerShell script to check last backup date for Databases

,

Open powershell console in your desktop, use your server name, instance name, user name and password. You can customize this script,  like out put the result into a .txt format by using  | out-file “Path\fileName.txt” or use other parameter like “recovery model”

I got help regarding tip from http://www.mssqltips.com/sqlservertip/1784/check-the-last-sql-server-backup-date-using-windows-powershell/

[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO')| out-null
$srv = new-object ('Microsoft.SqlServer.Management.Smo.Server') "ServerName\InstanceName" 
$srv.ConnectionContext.LoginSecure=$True; 

## If Using SQL Authentication
##$srv.ConnectionContext.LoginSecure=$False; 
##$srv.ConnectionContext.set_Login("UserName"); 
##$srv.ConnectionContext.set_Password("PassWord") 

$srv.Databases | select name, recoverymodel, lastbackupdate, lastlogBackupDate | ft  -Wrap –AutoSize

this

Rate

4 (1)

You rated this post out of 5. Change rating

Share

Share

Rate

4 (1)

You rated this post out of 5. Change rating