Powershell for SQL Server

For me, dbatools is the best tool around for scripting SQL Sever tasks. It is a PowerShell module made by DBAs for doing DBA stuff. I’m not a DBA, but I need to script database steps in our deployment process at work. I have previously used SQLPS to do some tasks, but finding information was hard and getting it to run reliably in different environments was difficult. SQLPS is part of the SQL Server installation so you need to have access to that to get it. The updated module, SqlServer is available from the PowerShell Gallery which is better when you need to install it, but I still had trouble getting my scripts to run reliably. With dbatools, success has been pretty easy.

Seriously, hop on over to dbatools.io and check it out. Scroll down on the home page and read the endorsements. And then try it out. Use the awesome documentation to see how PowerShell documentation should be done, as well as inform you on how to use the commands. If you need to script SQL Server using PowerShell, this is probably the tool you want to use.

Go a step further and get the source code. Use it like I do, as a resource to improve the way you code PowerShell.

Leave a comment