dbatools

SQL Server 自动化和实例迁移从未如此安全、快速或自由过。「🚀 SQL Server automation and instance migrations have never been safer, faster or freer」

Github星跟蹤圖

dbatools is PowerShell module that you may think of like a command-line SQL Server Management Studio. The project initially started out as just Start-SqlMigration.ps1, but has now grown into a collection of over 500 commands that help automate SQL Server tasks and encourage best practices.

Want to contribute to the project? We'd love to have you! Visit our contributing.md for a jump start.

Want to say thanks? Click the star at the top of the page ?

Need an invite to the SQL Community Slack workspace? Check out the self-invite page. Drop by if you'd like to chat about dbatools or even join the team!

Installer

dbatools now works on PowerShell Core (aka PowerShell 6+). This means that you can run a large majority of our commands on Linux and macOS ??

Run the following to install dbatools from the PowerShell Gallery (to install on a server or for all users, remove the -Scope parameter and run in an elevated session):

Install-Module dbatools -Scope CurrentUser

If you don't have a version of PowerShell that supports the PowerShell Gallery, you can install it manually:

Invoke-Expression (Invoke-WebRequest https://dbatools.io/in)

Note: please only use Invoke-Expression (Invoke-WebRequest..) from sources you trust, like us ?

Usage scenarios

In addition to the simple things you can do in SSMS (e.g. starting a job, backing up a database), we've also read a whole bunch of docs and came up with commands that do nifty things quickly.

  • Lost sysadmin access and need to regain entry to your SQL Server? Use Reset-DbaAdmin.
  • Need to easily test your backups? Use Test-DbaLastBackup.
  • SPN management got you down? Use our suite of SPN commands to find which SPNs are missing and easily add them.
  • Got so many databases you can't keep track? Congrats on your big ol' environment! Use Find-DbaDatabase to easily find your database.

Usage examples

As previously mentioned, dbatools now offers over 500 commands! Here are some of the ones we highlight at conferences.

PowerShell v3 and above required. (See below for important information about alternative logins and specifying SQL Server ports).

# Set some vars
$new = "localhost\sql2016"
$old = $instance = "localhost"
$allservers = $old, $new

# Alternatively, use Registered Servers
$allservers = Get-DbaCmsRegServer -SqlInstance $instance

# Need to restore a database? It can be as simple as this:
Restore-DbaDatabase -SqlInstance $instance -Path "C:\temp\AdventureWorks2012-Full Database Backup.bak"

# Use Ola Hallengren's backup script? We can restore an *ENTIRE INSTANCE* with just one line
Get-ChildItem -Directory \\workstation\backups\sql2012

主要指標

概覽
名稱與所有者dataplat/dbatools
主編程語言PowerShell
編程語言PowerShell (語言數: 3)
平台Linux, Mac, Windows
許可證MIT License
所有者活动
創建於2015-02-02 23:50:31
推送於2025-04-07 11:21:10
最后一次提交2025-03-04 23:59:18
發布數221
最新版本名稱v2.1.30 (發布於 2025-03-04 23:58:29)
第一版名稱v0.8.5.53 (發布於 )
用户参与
星數2.5k
關注者數156
派生數829
提交數17.4k
已啟用問題?
問題數3602
打開的問題數271
拉請求數5251
打開的拉請求數3
關閉的拉請求數405
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?