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


This is the final piece in the Restore-DbaDatabase Stack. Uusally a BackupHistory object will arrive here from Restore-DbaDatabse via the following pipeline:
Get-DbaBackupInformation | Select-DbaBackupInformation | Format-DbaBackupInformation | Test-DbaBackupInformation | Invoke-DbaAdvancedRestore

We have exposed these functions publicly to allow advanced users to perform operations that we don’t support, or won’t add as they would make things too complex for the majority of our users.

For example if you wanted to do some very complex redirection during a migration, then doing the rewrite of destinations may be better done with your own custom scripts rather than via Format-DbaBackupInformation.

We would recommend ALWAYS pushing your input through Test-DbaBackupInformation just to make sure that it makes sense to us.




Will restore all the backups in the BackupHistory object according to the transformations it contains.

$BackupHistory | Invoke-DbaAdvancedRestore -SqlInstance MyInstance

First generates just the T-SQL restore scripts so they can be sanity checked, and then if they are good perform the full restore. By reusing the BackupHistory object there is no need to re-scan all the backup files again.

$BackupHistory | Invoke-DbaAdvancedRestore -SqlInstance MyInstance -OutputScriptOnly
$BackupHistory | Invoke-DbaAdvancedRestore -SqlInstance MyInstance


This command was created by Stuart Moore. You can find Stuart on Twitter and his blog.


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

Source Code

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

Related commands