At first this was simply going to get me back into the swing of writing some good old fashioned T-SQL again, and keep me from having to look in my notes for each domain share. The thought behind this automation endeavor was that it would enable me to work harder initially, but save team members time further down the road.

The first creation of the script was written only to get the latest full backup. That was it! Soon after though another restore request had to be fulfilled using DIFFs and LOGs, which pushed me to alter the script a little more, then a little more..... then a little more. What had started out with only a few lines of code, turned into over 900!

By utilizing the MSDB tables this script is obviously not very helpful if the instance is unavailable. However, something like dbatools does gives you that flexibility of pointing it to a share and letting it do the dirty work for you. I highly recommend looking into it! I know I know dbatools is great at migrations, restores and ending world hunger, but sometimes team members just aren't comfortable enough with powershell.

I've also used this script to show team members, and in speaking sessions, just how much work goes into something like dbatools behind the scenes.