SQL Server Tips

How to Install DBATools Powershell Module for SQL Server [Full Guide]

Updated October 29, 20254 min read

Written byMark Varnas
PowerShell SQL Server banner

What is dbatools and PowerShell?

Dbatools is an open-source module of PowerShell developed by big names from the SQL Server community, MVPs, and other SQL Server and PowerShell professionals. The dbatools uses SMO (server management objects) from the .Net framework, the same objects used bu SSMS (SQL Server management studio).

With SMO objects, we can manipulate any SQL Server object using the C# program language. In addition to SMO's widespread use, dbatools use the WMI/CIM (Windows Management Instrumentation/Common Information Model) to manipulate windows server objects.

With all this power, it is focused on the administrative tasks of SQL Server environments, implementing good practices for development, migration, and daily routines. dbatools.io currently has more than 500 commands to assist you in your daily activities.

How to install dbatools?

There is only one requirement: PowerShell v3+

Once you meet these requirements, installation is simple:

  • Open PowerShell command window with Administrator rights (Right Click on Window and select run as an administrator).
  • Run the following command: Install-Module dbatools.
Figure 1 - Install dbatools (Powershell command)
Figure 1 - Installing dbatools (Powershell command)
  • To give affirmative answers to the questions type Y (Yes) in the prompt.

That's it! You are done.

Installing dbatools offline

You can also use the offline method to install in your server when you don't have internet access.

  • First, download the package on dbatools.io/zip and copy it preferably to some path that is configured in your environment variable $ env: PSModulePath.
  • Open the Start Search, type in "env", and choose Edit the system environment variables.
  • Click the Environment Variables… button
Figure 2 - Environment variables
Figure 2 - Environment variables
  • After copying the package to one of the above locations, you can install dbatools using the command:
    • Import-Module -Name dbatools

How to check if dbatools was correctly installed?

One way is to use the Get-Module command presented below.

  • Get-Module dbatools -ListAvailable
Figure 3 - Checking if dbatools is installed
Figure 3 - Checking if dbatools is installed

If you don't receive that message, it may mean that the module is not installed on the machine or has not been loaded into the memory yet.

Getting started with dbatools

Let's navigate through PowerShell using the native cmdlets. Below are some commands that you will use in your everyday life.

  • Get-Command - List all package commands installed in the machine.
  • Get-Help - Get command details.
  • Get-command -Module dbatools - List all commands from dbatools module.
  • Get-command *Get-DbaSQL* - To filter the search, use the asterisk (*) wildcard character with the Name parameter.
  • Get-Help Get-DbaSqlService -Examples - The Examples parameter displays the help file's NAME and SYNOPSIS sections and all the Examples, as you can see below:
Get-Help Get-DbaSqlService -Examples
Get-Help Get-DbaSqlService -Examples

Get-Help Get-DbaSqlService -Detailed - The Detailed parameter displays the help article's detailed view that includes parameter descriptions and example, as you can see below:

Get-Help Get-DbaSqlService - detailed
Get-Help Get-DbaSqlService -Detailed

The better your knowledge of PowerShell is, the easier it will be to work with dbatools, and the easier it will be to extract rich information.

More information

The dbatools commands automate and simplify many of the tasks we've all had to do multiple times. Want to know more? Here are some great articles that focus on functionality:

Conclusion

PowerShell is everywhere. Learning PowerShell prepares you for the inevitable (and fun!) automation-rich future. Once you learn how to use an automation tool like PowerShell, you can easily transition your skills to automate everything from on-premise Instances (Windows/Linux) to the Azure SQL Database (it even helps power the cloud).

Discover More

Discover what clients are saying about Red9

Red9 has incredible expertise both in SQL migration and performance tuning.

The biggest benefit has been performance gains and tuning associated with migrating to AWS and a newer version of SQL Server with Always On clustering. Red9 was integral to this process. The deep knowledge of MSSQL and combined experience of Red9 have been a huge asset during a difficult migration. Red9 found inefficient indexes and performance bottlenecks that improved latency by over 400%.

Rich StaatsRich StaatsCloud EngineerMetalToad
See more testimonials

Check Red9's SQL Server Services

SQL Server Consulting

Perfect for one-time projects like SQL migrations or upgrades, and short-term fixes such as performance issues or SQL remediation.

Discover More ➜

SQL Server Managed Services

Continuous SQL support, proactive monitoring, and expert DBA help with one predictable monthly fee.

Discover More ➜

Emergency SQL Support

Take the stress out of emergencies with immediate access to a SQL Server Sr. DBA 24x7x365

Discover More ➜

Explore All Services ➜