{"id":13405486,"url":"https://github.com/dataplat/dbatools","last_synced_at":"2026-02-13T00:13:27.758Z","repository":{"id":26757362,"uuid":"30215226","full_name":"dataplat/dbatools","owner":"dataplat","description":"🚀 SQL Server automation and instance migrations have never been safer, faster or freer","archived":false,"fork":false,"pushed_at":"2025-04-07T11:21:10.000Z","size":70879,"stargazers_count":2558,"open_issues_count":280,"forks_count":832,"subscribers_count":156,"default_branch":"development","last_synced_at":"2025-05-06T08:17:16.987Z","etag":null,"topics":["backup","best-practices","database","database-administration","hacktoberfest","migrations","mssql","powershell","sql-server","sql-server-migration"],"latest_commit_sha":null,"homepage":"https://dbatools.io","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dataplat.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"license","code_of_conduct":"code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["potatoqualitee","Stuart-Moore","sanderstad","jpomfret"]}},"created_at":"2015-02-02T23:50:31.000Z","updated_at":"2025-05-05T09:48:57.000Z","dependencies_parsed_at":"2023-09-23T14:34:37.700Z","dependency_job_id":"0ac8bdd0-c44c-4007-9f5e-cd05111f0850","html_url":"https://github.com/dataplat/dbatools","commit_stats":{"total_commits":13185,"total_committers":377,"mean_commits":34.97347480106101,"dds":0.6169890026545317,"last_synced_commit":"50b1d2b6bb86a8ce026bcc23636dd8e2e5a72b17"},"previous_names":["sqlcollaborative/dbatools"],"tags_count":221,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplat%2Fdbatools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplat%2Fdbatools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplat%2Fdbatools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplat%2Fdbatools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dataplat","download_url":"https://codeload.github.com/dataplat/dbatools/tar.gz/refs/heads/development","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253011507,"owners_count":21840007,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","best-practices","database","database-administration","hacktoberfest","migrations","mssql","powershell","sql-server","sql-server-migration"],"created_at":"2024-07-30T19:02:03.564Z","updated_at":"2026-02-13T00:13:27.752Z","avatar_url":"https://github.com/dataplat.png","language":"PowerShell","readme":"# dbatools\n\n[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/dbatools)](https://www.powershellgallery.com/packages/dbatools)\n[![Downloads](https://img.shields.io/powershellgallery/dt/dbatools)](https://www.powershellgallery.com/packages/dbatools)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/dataplat/dbatools/integration-tests.yml?branch=development)](https://github.com/dataplat/dbatools/actions)\n[![GitHub Stars](https://img.shields.io/github/stars/dataplat/dbatools?style=social)](https://github.com/dataplat/dbatools)\n\n\u003cimg align=\"left\" src=\"https://raw.githubusercontent.com/dataplat/dbatools/development/bin/dbatools.png\" alt=\"dbatools logo\"\u003e\n\n**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.\n\n**Performance at Scale:** Migrate terabyte databases in under an hour. Test 1000+ backups per hour. Manage 100+ SQL instances from a single console.\n\n## Table of Contents\n- [Why dbatools?](#why-dbatools)\n- [Quick Start](#quick-start)\n- [System Requirements](#system-requirements)\n- [Common Use Cases](#common-use-cases)\n- [Installation](#installation)\n- [Getting Help](#getting-help)\n- [Advanced Usage](#advanced-usage)\n- [Troubleshooting](#troubleshooting)\n- [Community \u0026 Support](#community--support)\n- [Contributing](#contributing)\n\n## Why dbatools?\n\n| Traditional Methods | dbatools |\n|-------------------|----------|\n| **SSMS:** Click through 50 servers manually | **PowerShell:** Query all 50 servers in one command |\n| **Migration:** Days of planning and execution | **Migration:** Minutes with automated best practices |\n| **Backup Testing:** Manual restores, hope for the best | **Backup Testing:** Automated verification of all backups |\n| **Documentation:** Hours of manual collection | **Documentation:** Instant HTML/Excel reports |\n| **Scripting:** Complex T-SQL across versions | **Scripting:** Consistent commands for SQL 2000-2022 |\n\n## Quick Start\n\n```powershell\n# Check your PowerShell version (v3+ required for Windows, Core 7.4+ for Linux/macOS)\n$PSVersionTable.PSVersion\n\n# Install (Windows/Linux/macOS)\nInstall-Module dbatools -Scope CurrentUser\n\n# See your databases\nGet-DbaDatabase -SqlInstance localhost\n\n# Check your backups\nGet-DbaLastBackup -SqlInstance localhost | Format-Table\n\n# Test your last backup (yes, really!)\nTest-DbaLastBackup -SqlInstance localhost\n```\n\n## System Requirements\n\n### SQL Server Support\n| Version | Commands Supported |\n|---------|-------------------|\n| SQL Server 2000 | 75% |\n| SQL Server 2005 | 90% |\n| SQL Server 2008/R2 | 93% |\n| SQL Server 2012+ | 100% |\n| Azure SQL VM | As per version above |\n| Azure SQL Database | 40% |\n| Azure SQL Managed Instance | 60% |\n| Containers/Kubernetes | 75% |\n\n### Operating System Support\n| OS | Commands Supported | PowerShell Required |\n|----|-------------------|-------------------|\n| Windows 7/8/10/11 | 100% | v3+ |\n| Windows Server 2008 R2+ | 100% | v3+ |\n| Linux (Intel/ARM64) | 78% | Core 7.4.0+ |\n| macOS (Intel/M1) | 78% | Core 7.4.0+ |\n\n💡 **Note:** Commands requiring SQL WMI or `-ComputerName` parameter typically don't work on Linux/macOS.\n\n### Network Requirements\nFor remote SQL Server management, ensure these ports are accessible:\n\n| Protocol | Default Port | Used By | Required For | Firewall Note |\n|----------|-------------|---------|--------------|---------------|\n| SQL Database Engine | 1433 | `Get-DbaDatabase` | 62% of commands | Allow inbound on SQL Server |\n| WS-Management | 5985/5986 | `New-DbaClientAlias` | 25% of commands | Windows Remote Management |\n| SQL WMI | 135 | `Enable-DbaAgHadr` | 4% of commands | DCOM/RPC endpoint mapper |\n| SMB | 445 | `Backup-DbaDatabase` | 4% of commands | File sharing for backups |\n\n**Firewall Tip:** Create a dedicated Windows Firewall rule group for dbatools management traffic.\n\n## Common Use Cases\n\n### Backups \u0026 Restores\n```powershell\n# Backup all databases\nGet-DbaDatabase -SqlInstance sql01 | Backup-DbaDatabase\n\n# Simple restore\nRestore-DbaDatabase -SqlInstance sql01 -Path \"C:\\temp\\mydb.bak\"\n\n# Test ALL your backups on a different server\nTest-DbaLastBackup -SqlInstance sql01 -Destination sql02 | Out-GridView\n```\n\n### Migrations\n```powershell\n# Migrate entire SQL instance with one command\n$params = @{\n    Source = 'sql01'\n    Destination = 'sql02'\n    BackupRestore = $true\n    SharedPath = '\\\\nas\\temp'\n}\nStart-DbaMigration @params -Force\n\n# Copy jobs between servers\nCopy-DbaAgentJob -Source sql01 -Destination sql02\n```\n\n### Monitoring \u0026 Health\n```powershell\n# Find databases without recent backups\nGet-DbaLastBackup -SqlInstance sql01 |\n    Where-Object LastFullBackup -lt (Get-Date).AddDays(-7)\n\n# Check for corruption\nGet-DbaLastGoodCheckDb -SqlInstance sql01 | Out-GridView\n\n# Monitor currently running queries\nInstall-DbaWhoIsActive -SqlInstance sql01 -Database master\nInvoke-DbaWhoIsActive -SqlInstance sql01\n```\n\n### Finding \u0026 Discovery\n```powershell\n# Find databases across multiple servers\nFind-DbaDatabase -SqlInstance sql01, sql02, sql03 -Pattern \"Production\"\n\n# Find stored procedures containing specific text\nFind-DbaStoredProcedure -SqlInstance sql01 -Pattern \"INSERT INTO Audit\"\n\n# Discover SQL instances on network\nFind-DbaInstance -ComputerName server01, server02\n```\n\n## Installation\n\n### Prerequisites\n```powershell\n# Check your PowerShell version\n$PSVersionTable.PSVersion\n\n# Set execution policy (one-time setup)\nSet-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser\n\n# Trust PowerShell Gallery (one-time setup)\nSet-PSRepository -Name PSGallery -InstallationPolicy Trusted\n```\n\n### Install Methods\n\n#### For Current User (Recommended)\n```powershell\nInstall-Module dbatools -Scope CurrentUser\n```\n\n#### For All Users (Requires Admin)\n```powershell\nInstall-Module dbatools\n```\n\n#### Offline Installation\n```powershell\n# On internet-connected machine:\nSave-Module -Name dbatools -Path C:\\temp\n\n# Copy to target machine and place in:\n# - All users: C:\\Program Files\\WindowsPowerShell\\Modules\n# - Current user: $HOME\\Documents\\WindowsPowerShell\\Modules\n\n# Import the module after copying\nImport-Module dbatools\n```\n\n### ⚠️ Certificate Change Notice (v2.5.5+)\nStarting with v2.5.5, dbatools uses Microsoft Azure Trusted Signing. When upgrading from older versions:\n```powershell\nInstall-Module dbatools -Force -SkipPublisherCheck\n```\n[Full migration guide →](https://blog.netnerds.net/2025/08/dbatools-azure-trusted-signing/)\n\n## Getting Help\n\n```powershell\n# Detailed help for any command\nGet-Help Test-DbaLastBackup -Full\n\n# Find commands\nGet-Command -Module dbatools *backup*\nFind-DbaCommand -Tag Migration\n\n# Online help\nGet-Help Test-DbaLastBackup -Online\n```\n\n**Resources:**\n- 📚 [Documentation](https://docs.dbatools.io)\n- 🔍 [Command Reference](https://dbatools.io/commands)\n- 📰 [Blog](https://dbatools.io/blog)\n- 💬 [Slack Community](https://dbatools.io/slack)\n\n## Advanced Usage\n\n### Authentication\n\n#### SQL Authentication\n```powershell\n$cred = Get-Credential sqladmin\nGet-DbaDatabase -SqlInstance sql01 -SqlCredential $cred\n```\n\n#### Alternative Windows Credentials\n```powershell\n$cred = Get-Credential ad\\winadmin\nGet-DbaDiskSpace -ComputerName sql01 -Credential $cred\n```\n\n#### Storing Credentials Securely\nPowerShell's `Export-CliXml` provides a fast and secure way to store credentials to disk. The credentials are encrypted using Windows Data Protection API (DPAPI) and can only be decrypted by the same user on the same machine.\n\n```powershell\n# Save credentials to disk (one-time setup)\nGet-Credential | Export-CliXml -Path \"$HOME\\sql-credentials.xml\"\n\n# Reuse saved credentials in scripts\n$cred = Import-CliXml -Path \"$HOME\\sql-credentials.xml\"\nGet-DbaDatabase -SqlInstance sql01 -SqlCredential $cred\n```\n\nFor more advanced credential management approaches including the Secrets Management module, see [Rob Sewell's guide](https://blog.robsewell.com/blog/good-bye-import-clixml-use-the-secrets-management-module-for-your-labs-and-demos/).\n\n### Custom Ports\n```powershell\n# Using colon or comma for non-default ports\nGet-DbaDatabase -SqlInstance 'sql01:55559'\nGet-DbaDatabase -SqlInstance 'sql01,55559'  # Note: quotes required\n```\n\n### PowerShell Transcript\n```powershell\n# Import module before starting transcript (PS 5.1 requirement)\nImport-Module dbatools\nStart-Transcript\nGet-DbaDatabase -SqlInstance sql01\nStop-Transcript\n```\n\n## Troubleshooting\n\n### Using with Azure PowerShell (Az) or SqlServer Modules\n\nIf you use dbatools alongside the Az PowerShell module or Microsoft's SqlServer module in the same session, import them in this order to avoid assembly version conflicts:\n\n```powershell\n# 1. Import Az or SqlServer modules first\nImport-Module Az.Accounts\nImport-Module SqlServer\n\n# 2. Then import dbatools\nImport-Module dbatools\n```\n\nIf you still experience conflicts or need to use dbatools with other modules that have assembly conflicts, use the `-ArgumentList $true` parameter to enable conflict avoidance mode:\n\n```powershell\nImport-Module dbatools -ArgumentList $true\n```\n\nThis skips loading conflicting Azure assemblies when incompatible versions are already loaded.\n\n### Common Issues\n\n**Issue: \"Could not connect to SqlInstance\"**\n```powershell\n# Test connectivity\nTest-DbaConnection -SqlInstance sql01\n\n# Check if SQL Browser service is running for named instances\nGet-DbaService -ComputerName sql01 -Type Browser\n```\n\n**Issue: \"Access denied\" errors**\n```powershell\n# Ensure you have proper SQL permissions\nGet-DbaLogin -SqlInstance sql01 -Login $env:USERNAME\n\n# For Windows authentication issues, verify domain connectivity\nTest-ComputerSecureChannel\n```\n\n**Issue: Module won't import**\n```powershell\n# Check execution policy\nGet-ExecutionPolicy\n\n# Force reimport if needed\nRemove-Module dbatools -Force -ErrorAction SilentlyContinue\nImport-Module dbatools -Force\n```\n\nFor more troubleshooting help, visit our [troubleshooting guide](https://dbatools.io/troubleshooting/) or ask in [Slack](https://dbatools.io/slack).\n\n## Community \u0026 Support\n\n**Get Involved:**\n- ⭐ Star this repository\n- 🐛 [Report issues](https://github.com/dataplat/dbatools/issues)\n- 💡 [Request features](https://github.com/dataplat/dbatools/issues)\n- 🤝 [Contribute code](CONTRIBUTING.md)\n\n**Community Channels:**\n- [#dbatools on SQL Community Slack](https://sqlcommunity.slack.com/messages/C1M2WEASG/)\n- [#dbatools-dev for contributors](https://sqlcommunity.slack.com/messages/C3EJ852JD/)\n- [Twitter/X](https://twitter.com/psdbatools)\n\n**Stats:**\n- 📦 7+ million downloads on [PowerShell Gallery](https://www.powershellgallery.com/packages/dbatools)\n- 👥 250+ contributors\n- 🎯 700+ commands\n- 🚀 10+ years of active development\n\n## Contributing\n\nWe'd love to have you join us! Check out our [Contributing Guide](contributing.md) and the [dbatools-dev Slack channel](https://sqlcommunity.slack.com/messages/C3EJ852JD/).\n\n## License\n\ndbatools is licensed under the [MIT License](LICENSE).\n\n## Special Thanks\n\nThank you to all our [contributors](https://github.com/dataplat/dbatools/graphs/contributors) and the SQL Server community for making this project possible.\n","funding_links":["https://github.com/sponsors/potatoqualitee","https://github.com/sponsors/Stuart-Moore","https://github.com/sponsors/sanderstad","https://github.com/sponsors/jpomfret"],"categories":["PowerShell","best-practices"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataplat%2Fdbatools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdataplat%2Fdbatools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataplat%2Fdbatools/lists"}