The Surly Admin

Father, husband, IT Pro, cancer survivor

Announcing the PS.SQL Module

I’ve been doing a ton of work with SQL and PowerShell over the last year and a half and have come up with some pretty good tools to help me along the way.  We even built a module out of them at work and use it in a dozen or more scripts every day, when it finally occurred to me that my readers might like to use them too.  And the PS.SQL Module was born.

Continue reading

Advertisement

February 19, 2016 Posted by | MS SQL, PowerShell | , , , , | 2 Comments

SQL Backups Report

This is a simple report to tell you the status of your SQL Server backups.

Continue reading

June 8, 2015 Posted by | MS SQL, PowerShell | , | 11 Comments

SQL Backup File Name

As I’ve mentioned, I’m doing a ton of SQL work lately (more on that later!) and I just had a co-worker ask for something so I threw together this quick query.  One of our backups had failed and he just wanted to know where the backup file was being placed (in most cases we backup locally but we do have some exceptions).  I threw together this query to locate the file name:


SELECT bs.database_name AS Name,
bs.backup_finish_date AS LastBackup,
bmf.physical_device_name AS BackupFile
FROM msdb.dbo.backupmediafamily AS bmf
JOIN msdb.dbo.backupset AS bs
ON bmf.media_set_id = bs.media_set_id
WHERE bs.type = 'D'
ORDER BY bs.backup_finish_date DESC

I also have a new PowerShell script that reports on SQL backups that I want to get published, as well as a more intelligent index rebuilder that is Availability Group and log shipping aware.

Stay tuned!

May 11, 2015 Posted by | MS SQL, PowerShell | , | Leave a comment

SQL Queries in PowerShell

There are a whole bunch of blog posts and scripts out there to do SQL queries in PowerShell, so I’ve really hesitated about posting my own version of it.  But hey, it’s my blog and I can do what I want to.  Do what I want to.

Continue reading

December 1, 2014 Posted by | PowerShell | , , | 4 Comments