Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Restore-DbaDatabase. Set initial catalog to master #6346
$RestoreInstance is now set using Connect-DbaInstance instead of
Type of Change
So that if restoring a database which is the same as the one you are automatically connected to, the restore will no longer fail. It's not a common scenario but it happened to me today where my initial catalog was the same as the DB I wanted to restore.
It sets the database context to master for all connections.
Commands to test
Get-ChildItem '\BACKUPS\DBName1' | Restore-DbaDatabase -SqlInstance 'DEVSQL1' -DatabaseName 'DBName1' -UseDestinationDefaultDirectories -WithReplace
$RestoreInstance is now set using Connect-DbaInstance instead of Connect-Sqlinstance. This change means that instead of connecting to the inital catalogue based on your SQL login, you will always connect to master before restoring the database. This is needed in case your default connection puts you in the context of the database you are trying to restore.