Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass -Force through From Copy-DbaDatabase o Set-DbaDbState (Fixes #5055) #5057

Merged
merged 1 commit into from
Feb 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions functions/Copy-DbaDatabase.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 $_
}
Expand Down