I write about SQL Server automation often, and dbatools comes up frequently. Instead of rewriting install steps in every post, I’m putting them here once so I can just link back.
The full instructions are on the official site: dbatools.io/download. If you’re new to dbatools, follow those first—they’re always current. You should also check out their Getting Started page: dbatools.io/getting-started while you’re there since it has many great examples to give you ideas for your next automation project.
The process is simple. From an admin PowerShell session:
Install-Module dbatools -Scope CurrentUser
If you’re prompted about trusting the repository, say yes… it’s the official source. On older systems you may also need to explicitly trust PSGallery with:
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Check that it worked:
Get-Command -Module dbatools
Keep it updated periodically with this command:
Update-Module dbatools
Note: If you get errors about script execution policy, you may need to allow PowerShell to run downloaded modules. The simplest way is:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUserThat lets you run modules you install from the Gallery while still keeping protections in place.
That’s all you need for most cases. For older Windows versions or locked-down environments, see alternate installation methods on the official download page.