4 A Gentle Introduction to dbatools commands

 

Now you should be all set up and ready to start working with dbatools. In this chapter, you will learn about a few new commands and four of the common dbatools parameters: SqlInstance, SqlCredential, ComputerName and Credential.

These parameters are particularly useful because they are used in nearly every command to connect to both local and remote servers. The primary goal of this chapter is to get you comfortable with these common parameters. You will see them used throughout this book and in all of the dbatools that you will write in the future. Having consistent parameters throughout the entire module was a high priority for the 1.0 release of dbatools.

4.1  Getting started

As DBAs it is in our nature to be wary; we want to understand what a tool is going to do before we let it anywhere near our production environment. For this reason, we’ll start with commands that are read-only.

The first command that we have chosen to use is one that will help you to check that you are able to connect to the SQL Server instances. We figure that this was a good place to start because if you can’t connect to the SQL Server instance, then you will not be able to use any of the dbatools commands.

4.2  Checking the SQL connection

4.3  First, getting help

4.4  Now, run your first dbatools command

4.5  The SqlInstance parameter

4.5.1  Single Instances

4.5.2  Multiple instances

4.6  The SqlCredential parameter

4.6.1  Connecting to Instances with SQL Authentication

4.6.2  Saving the credential to use SQL Authentication with multiple commands

4.6.3  Other methods of using credentials for SQL Authentication

4.6.4  Connecting to Instances with a different Windows Account

4.7  The ComputerName parameter

4.7.1  Methods of listing the SQL services on multiple servers

4.8  The Credential parameter

4.8.1  List Services on a server using a different account at the command line

4.8.2  List Services on a server using a different account with a credential variable

4.8.3  Listing SQL Services by type

4.10  Hands On Lab

sitemap