Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🚀 SQL Server automation and instance migrations have never been safer, faster or freer

License

NotificationsYou must be signed in to change notification settings

dataplat/dbatools

PowerShell GalleryDownloadsBuild StatusGitHub Stars

dbatools logo

Migrate SQL Server instances in minutes instead of days. Test hundreds of backups automatically. Find that one database across 50 servers. dbatools is a PowerShell module with nearly 700 commands that replace manual SQL Server administration with powerful and fun automation.

Performance at Scale: Migrate terabyte databases in under an hour. Test 1000+ backups per hour. Manage 100+ SQL instances from a single console.

Table of Contents

Why dbatools?

Traditional Methodsdbatools
SSMS: Click through 50 servers manuallyPowerShell: Query all 50 servers in one command
Migration: Days of planning and executionMigration: Minutes with automated best practices
Backup Testing: Manual restores, hope for the bestBackup Testing: Automated verification of all backups
Documentation: Hours of manual collectionDocumentation: Instant HTML/Excel reports
Scripting: Complex T-SQL across versionsScripting: Consistent commands for SQL 2000-2022

Quick Start

# Check your PowerShell version (v3+ required for Windows, Core 7.4+ for Linux/macOS)$PSVersionTable.PSVersion# Install (Windows/Linux/macOS)Install-Module dbatools-Scope CurrentUser# See your databasesGet-DbaDatabase-SqlInstance localhost# Check your backupsGet-DbaLastBackup-SqlInstance localhost|Format-Table# Test your last backup (yes, really!)Test-DbaLastBackup-SqlInstance localhost

System Requirements

SQL Server Support

VersionCommands Supported
SQL Server 200075%
SQL Server 200590%
SQL Server 2008/R293%
SQL Server 2012+100%
Azure SQL VMAs per version above
Azure SQL Database40%
Azure SQL Managed Instance60%
Containers/Kubernetes75%

Operating System Support

OSCommands SupportedPowerShell Required
Windows 7/8/10/11100%v3+
Windows Server 2008 R2+100%v3+
Linux (Intel/ARM64)78%Core 7.4.0+
macOS (Intel/M1)78%Core 7.4.0+

💡Note: Commands requiring SQL WMI or-ComputerName parameter typically don't work on Linux/macOS.

Network Requirements

For remote SQL Server management, ensure these ports are accessible:

ProtocolDefault PortUsed ByRequired ForFirewall Note
SQL Database Engine1433Get-DbaDatabase62% of commandsAllow inbound on SQL Server
WS-Management5985/5986New-DbaClientAlias25% of commandsWindows Remote Management
SQL WMI135Enable-DbaAgHadr4% of commandsDCOM/RPC endpoint mapper
SMB445Backup-DbaDatabase4% of commandsFile sharing for backups

Firewall Tip: Create a dedicated Windows Firewall rule group for dbatools management traffic.

Common Use Cases

Backups & Restores

# Backup all databasesGet-DbaDatabase-SqlInstance sql01|Backup-DbaDatabase# Simple restoreRestore-DbaDatabase-SqlInstance sql01-Path"C:\temp\mydb.bak"# Test ALL your backups on a different serverTest-DbaLastBackup-SqlInstance sql01-Destination sql02|Out-GridView

Migrations

# Migrate entire SQL instance with one command$params=@{Source='sql01'Destination='sql02'BackupRestore=$trueSharedPath='\\nas\temp'}Start-DbaMigration@params-Force# Copy jobs between serversCopy-DbaAgentJob-Source sql01-Destination sql02

Monitoring & Health

# Find databases without recent backupsGet-DbaLastBackup-SqlInstance sql01|Where-Object LastFullBackup-lt (Get-Date).AddDays(-7)# Check for corruptionGet-DbaLastGoodCheckDb-SqlInstance sql01|Out-GridView# Monitor currently running queriesInstall-DbaWhoIsActive-SqlInstance sql01-Database masterInvoke-DbaWhoIsActive-SqlInstance sql01

Finding & Discovery

# Find databases across multiple serversFind-DbaDatabase-SqlInstance sql01, sql02, sql03-Pattern"Production"# Find stored procedures containing specific textFind-DbaStoredProcedure-SqlInstance sql01-Pattern"INSERT INTO Audit"# Discover SQL instances on networkFind-DbaInstance-ComputerName server01, server02

Installation

Prerequisites

# Check your PowerShell version$PSVersionTable.PSVersion# Set execution policy (one-time setup)Set-ExecutionPolicy-ExecutionPolicy RemoteSigned-Scope CurrentUser# Trust PowerShell Gallery (one-time setup)Set-PSRepository-Name PSGallery-InstallationPolicy Trusted

Install Methods

For Current User (Recommended)

Install-Module dbatools-Scope CurrentUser

For All Users (Requires Admin)

Install-Module dbatools

Offline Installation

# On internet-connected machine:Save-Module-Name dbatools-Path C:\temp# Copy to target machine and place in:# - All users: C:\Program Files\WindowsPowerShell\Modules# - Current user: $HOME\Documents\WindowsPowerShell\Modules# Import the module after copyingImport-Module dbatools

⚠️ Certificate Change Notice (v2.5.5+)

Starting with v2.5.5, dbatools uses Microsoft Azure Trusted Signing. When upgrading from older versions:

Install-Module dbatools-Force-SkipPublisherCheck

Full migration guide →

Getting Help

# Detailed help for any commandGet-HelpTest-DbaLastBackup-Full# Find commandsGet-Command-Module dbatools*backup*Find-DbaCommand-Tag Migration# Online helpGet-HelpTest-DbaLastBackup-Online

Resources:

Advanced Usage

Authentication

SQL Authentication

$cred=Get-Credential sqladminGet-DbaDatabase-SqlInstance sql01-SqlCredential$cred

Alternative Windows Credentials

$cred=Get-Credential ad\winadminGet-DbaDiskSpace-ComputerName sql01-Credential$cred

Custom Ports

# Using colon or comma for non-default portsGet-DbaDatabase-SqlInstance'sql01:55559'Get-DbaDatabase-SqlInstance'sql01,55559'# Note: quotes required

PowerShell Transcript

# Import module before starting transcript (PS 5.1 requirement)Import-Module dbatoolsStart-TranscriptGet-DbaDatabase-SqlInstance sql01Stop-Transcript

Troubleshooting

Common Issues

Issue: "Could not connect to SqlInstance"

# Test connectivityTest-DbaConnection-SqlInstance sql01# Check if SQL Browser service is running for named instancesGet-DbaService-ComputerName sql01-Type Browser

Issue: "Access denied" errors

# Ensure you have proper SQL permissionsGet-DbaLogin-SqlInstance sql01-Login$env:USERNAME# For Windows authentication issues, verify domain connectivityTest-ComputerSecureChannel

Issue: Module won't import

# Check execution policyGet-ExecutionPolicy# Force reimport if neededRemove-Module dbatools-Force-ErrorAction SilentlyContinueImport-Module dbatools-Force

For more troubleshooting help, visit ourtroubleshooting guide or ask inSlack.

Community & Support

Get Involved:

Community Channels:

Stats:

  • 📦 7+ million downloads onPowerShell Gallery
  • 👥 250+ contributors
  • 🎯 700+ commands
  • 🚀 10+ years of active development

Contributing

We'd love to have you join us! Check out ourContributing Guide and thedbatools-dev Slack channel.

License

dbatools is licensed under theMIT License.

Special Thanks

Thank you to all ourcontributors and the SQL Server community for making this project possible.

About

🚀 SQL Server automation and instance migrations have never been safer, faster or freer

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

  •  
  •  
  •  
  •  

Packages

No packages published

Contributors265


[8]ページ先頭

©2009-2025 Movatter.jp