Open source · dbatools

dbatools: managing SQL Server with PowerShell

Checking forty instances for the same setting, test-restoring the latest backups, moving logins and jobs to a new server: for routine work like this there has been dbatools since 2015, a free PowerShell module with over 700 commands for SQL Server. It came out of the SQL Server community, and the community still maintains it.

Tested with dbatools 2.9.1 on Nov 17, 2026 · approx. 7 min read

Series dbatoolsTested with dbatools 2.9.1Lab SQL Server 2017–2025
PS>Test-DbaMaxDop -SqlInstance $all40 instances36 as recommended3 deviations1 warning only

This page explains what dbatools is, how to get started safely, and which parts of the series help with which task. We ran every command we show with dbatools 2.9.1 against SQL Server 2017, 2019, 2022 and 2025. Our test setup and what it covers are described under Method and limits.

In 60 seconds

  • A community project. dbatools has been public since February 2015, uses the MIT license, and according to the project has over 250 contributors. Version 2.9.1 contains over 700 commands and about 750 test files; new versions appear at least monthly.
  • Commands by task. Get- reads, Test- checks against a rule, Copy- transfers between instances, Set- changes, Install- installs community scripts. Almost every command accepts several instances at once.
  • Runs on Windows, Linux and macOS. On Linux and macOS it needs PowerShell 7.4 or newer. About 160 commands need Windows features and run only there.
  • The first hurdle is the connection. Since version 2, dbatools encrypts every connection; it has validated the server certificate since version 1.1. Against servers with a self-signed certificate, the first call fails. Part 1 shows how to solve this without turning encryption off.
  • Green covers exactly the rule. The Test- commands work with what SQL Server reports about itself. They know little or nothing about other instances on the same server, other services or your workload (part 3).
  • Really test your backups. Test-DbaLastBackup restores the latest backup and runs DBCC CHECKDB. Without further parameters, it does so on the production server itself (part 4).

What dbatools is

dbatools consists of two modules. dbatools contains the commands, dbatools.library contains the .NET libraries they build on: SQL Server Management Objects (SMO) and the database driver Microsoft.Data.SqlClient. In our lab these were dbatools 2.9.1 and dbatools.library 2026.9.14 with SqlClient 7.0 and SMO 18.100. Install-Module dbatools fetches both.

The commands follow the PowerShell verbs. If you know the pattern, you find most commands without searching:

VerbWhat it doesExamples
Get-Dba…reads state and configurationGet-DbaDatabase, Get-DbaLastBackup, Get-DbaAgentJob
Test-Dba…compares against a rule or tries something outTest-DbaMaxDop, Test-DbaTempDbConfig, Test-DbaLastBackup
Copy-Dba…transfers objects between instancesCopy-DbaLogin, Copy-DbaAgentJob, Copy-DbaDatabase
Set-Dba…changes settingsSet-DbaMaxDop, Set-DbaMaxMemory
Install-Dba…installs community scriptsInstall-DbaMaintenanceSolution, Install-DbaWhoIsActive
Start-, Invoke-larger workflows and free-form queriesStart-DbaMigration, Invoke-DbaQuery

Two properties make the module strong in daily work. First, almost every command accepts a whole list of instances with -SqlInstance; the same check then runs across all of them. Second, the commands return objects instead of text, which you can filter, sort, and write to CSV or to a table.

A first run in the lab looked like this:

Import-Module dbatools
$cred = Get-Credential sa     # SQL login; the password is prompted
# -TrustServerCertificate: lab shortcut for self-signed certificates, see part 1
$s = Connect-DbaInstance -SqlInstance sql2022 -SqlCredential $cred -TrustServerCertificate
Get-DbaDatabase -SqlInstance $s

On the fresh instance, the four system databases master, tempdb, model and msdb came back. Without -TrustServerCertificate, none came back, but we got two warnings. Why that is, and why you should not wait for an error message here, is covered in part 1.

Project and community

dbatools is volunteer work that many teams use in operations every day. The project's figures (as of 17 November 2026):

  • Age and cadence: public since February 2015; in 2026, 15 versions appeared by October, the latest being 2.9.1 of Oct 15, 2026.
  • Size: 723 public command files and 752 test files in the 2.9.1 source; the command browser on dbatools.io counts 727 commands.
  • Contributors: over 250 according to the project.
  • Adoption: the PowerShell Gallery counted about 9.2 million downloads across all versions, about 165,000 of them for 2.9.1.
  • Learning resources: the command browser with one page per command, the book "Learn dbatools in a Month of Lunches" by Chrissy LeMaire, Rob Sewell, Jess Pomfret and Cláudio Silva (Manning, 2022, written before version 2), and the #dbatools channel in the SQL Community Slack.
567run anywhere: Windows, Linux, macOS160Windows onlyOne dot is one command. Command browser on dbatools.io, counted on Nov 17, 2026, dbatools 2.9.1.
567run anywhere: Windows, Linux, macOS160Windows onlyOne dot is one command. Command browser ondbatools.io, counted on Nov 17, 2026, dbatools2.9.1.
How many commands run on Linux and macOS: the command browser marks every command as “Runs anywhere” or “Windows only”. The Windows commands need WMI, remoting or Windows services, for example.

dbatools also integrates the work of other community projects instead of rebuilding it. Install-DbaMaintenanceSolution fetches Ola Hallengren's maintenance solution, Install-DbaFirstResponderKit the First Responder Kit, Install-DbaWhoIsActive Adam Machanic's sp_WhoIsActive, and Invoke-DbaDiagnosticQuery runs Glenn Berry's diagnostic queries. The help texts name the authors. The three Install- commands download the scripts from the authors' projects on GitHub. Glenn Berry's queries, by contrast, ship with dbatools itself; if you need a newer version from his site, pass it with -Path.

Where our tests turned up behavior that does not match the help, we name the version, the test setup and the place in the source. Several of the affected features are recent and were added at the community's request. As of 16 November 2026, we found no report in the project for any of these findings. The maintainers have already fixed a related bug with -VerifyOnly; on 17 November 2026, however, the fix had not yet been released.

Four principles for using it

  1. Pin the version. Install a specific, signed version and update deliberately. Our findings apply to 2.9.1; a newer version can change them (part 1).
  2. Do not turn encryption off across the board. Set-DbatoolsInsecureConnection removes the certificate errors, but it also turns encryption off and applies permanently. For labs, -TrustServerCertificate per connection is enough; for production, a proper certificate belongs on the server (part 1).
  3. Run commands that write with -WhatIf first, then on a test target. Commands that change something support -WhatIf and -Confirm. Commands that only read can also generate load: without -Destination, Test-DbaLastBackup restores on the source instance (part 4).
  4. Read the result, don't just wait for errors. Many commands report problems as a warning and return an empty result. A script that only watches for errors mistakes "no connection" for "no findings" (part 1, part 3).

Where to start

The series

Further parts are planned on taking inventory across many instances, logins and permissions, migration, Agent jobs and maintenance scripts, Availability Groups, automated checks, and dbatools on Linux.

Method and limits

  • Two labs: The main lab runs on Linux with SQL Server in containers, which lets us test four versions side by side and reproducibly. In addition, there is a Windows server with two instances. There we checked what only works on Windows or might behave differently there: signature, storage of settings, instance count, WMI checks, shares and -CopyFile. The findings about the logic of the commands themselves held up on Windows, for example the lost trust with connection objects. Where a result applies to only one system, or where we only derive it, we say so.
  • Software: dbatools 2.9.1 with dbatools.library 2026.9.14, PowerShell 7.6.8 on Linux in the image mcr.microsoft.com/dotnet/sdk:10.0. We loaded the modules as packages from the PowerShell Gallery and compared their checksums with the Gallery's figures.
  • Servers: SQL Server 2017 CU31, 2019 CU32, 2022 CU27 and 2025 CU9 in Linux containers on a host with 24 logical CPUs and cgroup v2; runs on Nov 13 and 16, 2026.
  • Source code: For the commands we cite, we read the relevant places in the 2.9.1 source, not the whole module. Whether reports for our findings already exist, we searched in the issues and pull requests on GitHub on 16 November 2026.
  • Windows: Windows Server 2022 as a VM with two instances of SQL Server 2022 RTM and Integration Services, dbatools 2.9.1 under Windows PowerShell 5.1 with Windows authentication; run on Nov 17, 2026.
  • Not tested: a Windows client against remote Windows servers, domains, and PowerShell 7 on Windows. What we describe only from documentation and source code is marked as such.

Further reading