From e11261dd51779d20f7fe3618d639d110dd2a3834 Mon Sep 17 00:00:00 2001 From: Tunney Date: Wed, 6 Feb 2019 09:55:18 -0500 Subject: [PATCH] Pass -Force through to Set-DbaDbState --- functions/Copy-DbaDatabase.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/Copy-DbaDatabase.ps1 b/functions/Copy-DbaDatabase.ps1 index 89b532467c..db6a63cc99 100644 --- a/functions/Copy-DbaDatabase.ps1 +++ b/functions/Copy-DbaDatabase.ps1 @@ -120,7 +120,9 @@ function Copy-DbaDatabase { Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch. .PARAMETER Force - If this switch is enabled, existing databases on Destination with matching names from Source will be dropped. If using -DetachReattach, mirrors will be broken and the database(s) dropped from Availability Groups. + If this switch is enabled, existing databases on Destination with matching names from Source will be dropped. + If using -DetachReattach, mirrors will be broken and the database(s) dropped from Availability Groups. + If using -SetSourceReadonly, this will instantly roll back any open transactions that may be stopping the process. .NOTES Tags: Migration, Backup, Restore @@ -1113,7 +1115,7 @@ function Copy-DbaDatabase { If ($Pscmdlet.ShouldProcess($source, "Set $dbName to read-only")) { Write-Message -Level Verbose -Message "Setting database to read-only." try { - $result = Set-DbaDbState -SqlInstance $sourceServer -Database $dbName -ReadOnly -EnableException + $result = Set-DbaDbState -SqlInstance $sourceServer -Database $dbName -ReadOnly -EnableException -Force:$Force } catch { Stop-Function -Continue -Message "Couldn't set database to read-only. Aborting routine for this database" -ErrorRecord $_ }