You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: public/Copy-DbaDatabase.ps1
+11-3Lines changed: 11 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1397,9 +1397,17 @@ function Copy-DbaDatabase {
1397
1397
$NewDatabase.Alter()
1398
1398
Write-Message-Level Verbose -Message "Successfully updated BrokerEnabled to $sourceDbBrokerEnabled for $destinationDbName on $destinstance."
1399
1399
} catch {
1400
-
Write-Message-Level Warning -Message "Failed to update BrokerEnabled to $sourceDbBrokerEnabled for $destinationDbName on $destinstance."
1401
-
1402
-
$propfailures+="Message broker"
1400
+
try {
1401
+
Write-Message-Level Verbose -Message "Updating BrokerEnabled to $sourceDbBrokerEnabled for $destinationDbName on $destinstance failed so we try to regenerate the broker identifier."
1402
+
$quotedDatabaseName=$destserver.Query("SELECT QUOTENAME('$($destinationDbName.Replace("'","''"))') AS quotename").quotename
1403
+
$null=$destserver.Query("ALTER DATABASE $quotedDatabaseName SET NEW_BROKER WITH ROLLBACK IMMEDIATE")
1404
+
$NewDatabase.BrokerEnabled=$sourceDbBrokerEnabled
1405
+
$null=$NewDatabase.Alter()
1406
+
Write-Message-Level Verbose -Message "Successfully updated BrokerEnabled to $sourceDbBrokerEnabled for $destinationDbName on $destinstance."
1407
+
} catch {
1408
+
Write-Message-Level Warning -Message "Failed to update BrokerEnabled to $sourceDbBrokerEnabled for $destinationDbName on $destinstance."
0 commit comments