dbatools is a free PowerShell module with over 300 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Clones a database schema and statistics.

This can be useful for testing query performance without requiring all the space needed for the data in the database.

Read more at sqlperformance.

Thanks to Microsoft Tiger Team for the code and idea.




Clones mydb to myclone on sql2016.

Invoke-DbaDatabaseClone -SqlInstance sql2016 -Database mydb -CloneDatabase myclone

Updates the statistics of mydb then clones to myclone and myclone2.

Invoke-DbaDatabaseClone -SqlInstance sql2016 -Database mydb -CloneDatabase myclone, myclone2 -UpdateStatistics


This command was created by Chrissy LeMaire. You can find Chrissy on Twitter.


From PowerShell, execute Get-Help Invoke-DbaDatabaseClone -Detailed for more information on this function.

Source Code

Want to see the source code? View Invoke-DbaDatabaseClone.ps1 on GitHub

Related commands