diff --git a/public/Copy-DbaDatabase.ps1 b/public/Copy-DbaDatabase.ps1 index 8f5137ab15..d62450d843 100644 --- a/public/Copy-DbaDatabase.ps1 +++ b/public/Copy-DbaDatabase.ps1 @@ -1001,7 +1001,7 @@ function Copy-DbaDatabase { SourceServer = $sourceServer.Name DestinationServer = $destServer.Name Name = $dbName - DestinationDatabase = $DestinationDbname + DestinationDatabase = $destinationDbName Type = "Database" Status = $null Notes = $null @@ -1100,26 +1100,26 @@ function Copy-DbaDatabase { continue } - if (($null -ne $destServer.Databases[$DestinationdbName]) -and !$force -and !$WithReplace -and !$Continue) { - if ($Pscmdlet.ShouldProcess($destinstance, "$DestinationdbName exists at destination. Use -Force to drop and migrate. Aborting routine for this database.")) { - Write-Message -Level Verbose -Message "$DestinationdbName exists at destination. Use -Force to drop and migrate. Aborting routine for this database." + if (($null -ne $destServer.Databases[$destinationDbName]) -and !$force -and !$WithReplace -and !$Continue) { + if ($Pscmdlet.ShouldProcess($destinstance, "$destinationDbName exists at destination. Use -Force to drop and migrate. Aborting routine for this database.")) { + Write-Message -Level Verbose -Message "$destinationDbName exists at destination. Use -Force to drop and migrate. Aborting routine for this database." $copyDatabaseStatus.Status = "Skipped" $copyDatabaseStatus.Notes = "Already exists on destination" $copyDatabaseStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject } continue - } elseif ($null -ne $destServer.Databases[$DestinationdbName] -and $force) { - if ($sourceServer.Name -eq $destServer.Name -and $sourceServer.Databases[$DestinationdbName].Name -eq $destServer.Databases[$DestinationdbName].Name) { + } elseif ($null -ne $destServer.Databases[$destinationDbName] -and $force) { + if ($sourceServer.Name -eq $destServer.Name -and $dbName -eq $destinationDbName) { Write-Message -Level Verbose -Message "Source and destination database are the same. Aborting routine for this database." $copyDatabaseStatus.Status = "Failed" $copyDatabaseStatus.Notes = "Source and destination database are the same." $copyDatabaseStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject continue } - if ($Pscmdlet.ShouldProcess($destinstance, "DROP DATABASE $DestinationdbName")) { - Write-Message -Level Verbose -Message "$DestinationdbName already exists. -Force was specified. Dropping $DestinationdbName on $destinstance." - $removeresult = Remove-DbaDatabase -SqlInstance $destserver -Database $DestinationdbName -Confirm:$false + if ($Pscmdlet.ShouldProcess($destinstance, "DROP DATABASE $destinationDbName")) { + Write-Message -Level Verbose -Message "$destinationDbName already exists. -Force was specified. Dropping $destinationDbName on $destinstance." + $removeresult = Remove-DbaDatabase -SqlInstance $destserver -Database $destinationDbName -Confirm:$false $dropResult = $removeresult.Status -eq 'Dropped' if ($dropResult -eq $false) { @@ -1213,9 +1213,9 @@ function Copy-DbaDatabase { try { $msg = $null if ($miRestore) { - $restoreResultTmp = $backupTmpResult | Restore-DbaDatabase -SqlInstance $destServer -DatabaseName $DestinationdbName -TrustDbBackupHistory -WithReplace:$WithReplace -EnableException -AzureCredential $AzureCredential + $restoreResultTmp = $backupTmpResult | Restore-DbaDatabase -SqlInstance $destServer -DatabaseName $destinationDbName -TrustDbBackupHistory -WithReplace:$WithReplace -EnableException -AzureCredential $AzureCredential } else { - $restoreResultTmp = $backupTmpResult | Restore-DbaDatabase -SqlInstance $destServer -DatabaseName $DestinationdbName -ReuseSourceFolderStructure:$ReuseSourceFolderStructure -NoRecovery:$NoRecovery -TrustDbBackupHistory -WithReplace:$WithReplace -Continue:$Continue -EnableException -ReplaceDbNameInFile -AzureCredential $AzureCredential -KeepCDC:$KeepCDC -KeepReplication:$KeepReplication + $restoreResultTmp = $backupTmpResult | Restore-DbaDatabase -SqlInstance $destServer -DatabaseName $destinationDbName -ReuseSourceFolderStructure:$ReuseSourceFolderStructure -NoRecovery:$NoRecovery -TrustDbBackupHistory -WithReplace:$WithReplace -Continue:$Continue -EnableException -ReplaceDbNameInFile -AzureCredential $AzureCredential -KeepCDC:$KeepCDC -KeepReplication:$KeepReplication } } catch { $msg = $_.Exception.InnerException.InnerException.InnerException.InnerException.Message @@ -1358,46 +1358,46 @@ function Copy-DbaDatabase { } } } - $NewDatabase = Get-DbaDatabase -SqlInstance $destServer -database $DestinationdbName + $NewDatabase = Get-DbaDatabase -SqlInstance $destServer -database $destinationDbName $propfailures = @() # restore potentially lost settings if ($destServer.VersionMajor -ge 9 -and $NoRecovery -eq $false) { if ($sourceDbOwnerChaining -ne $NewDatabase.DatabaseOwnershipChaining) { - if ($Pscmdlet.ShouldProcess($destinstance, "Updating DatabaseOwnershipChaining on $DestinationdbName")) { + if ($Pscmdlet.ShouldProcess($destinstance, "Updating DatabaseOwnershipChaining on $destinationDbName")) { try { $NewDatabase.DatabaseOwnershipChaining = $sourceDbOwnerChaining $NewDatabase.Alter() - Write-Message -Level Verbose -Message "Successfully updated DatabaseOwnershipChaining for $sourceDbOwnerChaining on $DestinationdbName on $destinstance." + Write-Message -Level Verbose -Message "Successfully updated DatabaseOwnershipChaining for $sourceDbOwnerChaining on $destinationDbName on $destinstance." } catch { - Write-Message -Level Warning -Message "Failed to update DatabaseOwnershipChaining for $sourceDbOwnerChaining on $DestinationdbName on $destinstance." + Write-Message -Level Warning -Message "Failed to update DatabaseOwnershipChaining for $sourceDbOwnerChaining on $destinationDbName on $destinstance." $propfailures += "Ownership chaining" } } } if ($sourceDbTrustworthy -ne $NewDatabase.Trustworthy) { - if ($Pscmdlet.ShouldProcess($destinstance, "Updating Trustworthy on $DestinationdbName")) { + if ($Pscmdlet.ShouldProcess($destinstance, "Updating Trustworthy on $destinationDbName")) { try { $NewDatabase.Trustworthy = $sourceDbTrustworthy $NewDatabase.Alter() - Write-Message -Level Verbose -Message "Successfully updated Trustworthy to $sourceDbTrustworthy for $DestinationdbName on $destinstance" + Write-Message -Level Verbose -Message "Successfully updated Trustworthy to $sourceDbTrustworthy for $destinationDbName on $destinstance" } catch { - Write-Message -Level Warning -Message "Failed to update Trustworthy to $sourceDbTrustworthy for $DestinationdbName on $destinstance." + Write-Message -Level Warning -Message "Failed to update Trustworthy to $sourceDbTrustworthy for $destinationDbName on $destinstance." $propfailures += "Trustworthy" } } } if ($sourceDbBrokerEnabled -ne $NewDatabase.BrokerEnabled) { - if ($Pscmdlet.ShouldProcess($destinstance, "Updating BrokerEnabled on $DestinationDbName")) { + if ($Pscmdlet.ShouldProcess($destinstance, "Updating BrokerEnabled on $destinationDbName")) { try { $NewDatabase.BrokerEnabled = $sourceDbBrokerEnabled $NewDatabase.Alter() - Write-Message -Level Verbose -Message "Successfully updated BrokerEnabled to $sourceDbBrokerEnabled for $DestinationdbName on $destinstance." + Write-Message -Level Verbose -Message "Successfully updated BrokerEnabled to $sourceDbBrokerEnabled for $destinationDbName on $destinstance." } catch { - Write-Message -Level Warning -Message "Failed to update BrokerEnabled to $sourceDbBrokerEnabled for $DestinationdbName on $destinstance." + Write-Message -Level Warning -Message "Failed to update BrokerEnabled to $sourceDbBrokerEnabled for $destinationDbName on $destinstance." $propfailures += "Message broker" } @@ -1406,15 +1406,15 @@ function Copy-DbaDatabase { } if ($sourceDbReadOnly -ne $NewDatabase.ReadOnly -and -not $NoRecovery) { - if ($Pscmdlet.ShouldProcess($destinstance, "Updating ReadOnly status on $DestinationdbName")) { + if ($Pscmdlet.ShouldProcess($destinstance, "Updating ReadOnly status on $destinationDbName")) { try { if ($sourceDbReadOnly) { - $result = Set-DbaDbState -SqlInstance $destserver -Database $DestinationdbName -ReadOnly -EnableException + $result = Set-DbaDbState -SqlInstance $destserver -Database $destinationDbName -ReadOnly -EnableException } else { - $result = Set-DbaDbState -SqlInstance $destserver -Database $DestinationdbName -ReadWrite -EnableException + $result = Set-DbaDbState -SqlInstance $destserver -Database $destinationDbName -ReadWrite -EnableException } } catch { - Write-Message -Level Verbose -Message "Failed to update ReadOnly status on $DestinationdbName." + Write-Message -Level Verbose -Message "Failed to update ReadOnly status on $destinationDbName." $propfailures = "Read only" } } diff --git a/tests/gh-actions.ps1 b/tests/gh-actions.ps1 index 9adbf0203f..8c7346dfc5 100644 --- a/tests/gh-actions.ps1 +++ b/tests/gh-actions.ps1 @@ -256,7 +256,7 @@ exec sp_addrolemember 'userrole','bob'; $results.Status | Should -Be "Successful" } - It "connects to Azure" { + It "connects to Azure" -Skip { $PSDefaultParameterValues.Clear() $securestring = ConvertTo-SecureString $env:CLIENTSECRET -AsPlainText -Force $azurecred = New-Object PSCredential -ArgumentList $env:CLIENTID, $securestring @@ -264,7 +264,7 @@ exec sp_addrolemember 'userrole','bob'; Connect-DbaInstance -SqlInstance "Server=dbatoolstest.database.windows.net; Authentication=Active Directory Service Principal; Database=test; User Id=$env:CLIENTID; Password=$env:CLIENTSECRET;" | Select-Object -ExpandProperty ComputerName | Should -Be "dbatoolstest.database.windows.net" } - It "gets a database from Azure" { + It "gets a database from Azure" -Skip { $PSDefaultParameterValues.Clear() $securestring = ConvertTo-SecureString $env:CLIENTSECRET -AsPlainText -Force $azurecred = New-Object PSCredential -ArgumentList $env:CLIENTID, $securestring @@ -272,7 +272,7 @@ exec sp_addrolemember 'userrole','bob'; (Get-DbaDatabase -SqlInstance $server -Database test).Name | Should -Be "test" } - It "tests Get-DbaLastGoodCheckDb against Azure" { + It "tests Get-DbaLastGoodCheckDb against Azure" -Skip { $PSDefaultParameterValues.Clear() $securestring = ConvertTo-SecureString $env:CLIENTSECRET -AsPlainText -Force $azurecred = New-Object PSCredential -ArgumentList $env:CLIENTID, $securestring @@ -297,4 +297,4 @@ Need to add tests for CSV 'Remove-DbaDatabaseSafely', 'Test-DbaManagementObject', 'Export-DbaDacPackage' -#> \ No newline at end of file +#> diff --git a/tests/gh-macactions.ps1 b/tests/gh-macactions.ps1 index 34f1adc53f..f3551d4fab 100644 --- a/tests/gh-macactions.ps1 +++ b/tests/gh-macactions.ps1 @@ -36,7 +36,7 @@ Describe "Integration Tests" -Tag "IntegrationTests" { $null = Remove-DbaDatabase -Database $db.Name } - It "connects to Azure" { + It "connects to Azure" -Skip { $PSDefaultParameterValues.Clear() $securestring = ConvertTo-SecureString $env:CLIENTSECRET -AsPlainText -Force $azurecred = New-Object PSCredential -ArgumentList $env:CLIENTID, $securestring @@ -44,7 +44,7 @@ Describe "Integration Tests" -Tag "IntegrationTests" { Connect-DbaInstance -SqlInstance "Server=dbatoolstest.database.windows.net; Authentication=Active Directory Service Principal; Database=test; User Id=$env:CLIENTID; Password=$env:CLIENTSECRET;" | Select-Object -ExpandProperty ComputerName | Should -Be "dbatoolstest.database.windows.net" } - It "gets a database from Azure" { + It "gets a database from Azure" -Skip { $PSDefaultParameterValues.Clear() $securestring = ConvertTo-SecureString $env:CLIENTSECRET -AsPlainText -Force $azurecred = New-Object PSCredential -ArgumentList $env:CLIENTID, $securestring diff --git a/tests/gh-winactions.ps1 b/tests/gh-winactions.ps1 index d6c103f984..6b6e3a31fe 100644 --- a/tests/gh-winactions.ps1 +++ b/tests/gh-winactions.ps1 @@ -33,7 +33,7 @@ Describe "Integration Tests" -Tag "IntegrationTests" { $null = Remove-DbaDatabase -Database $db.Name } - It "connects to Azure using tenant and client id + client secret" { + It "connects to Azure using tenant and client id + client secret" -Skip { $PSDefaultParameterValues.Clear() $securestring = ConvertTo-SecureString $env:CLIENTSECRET -AsPlainText -Force $azurecred = New-Object PSCredential -ArgumentList $env:CLIENTID, $securestring @@ -41,7 +41,7 @@ Describe "Integration Tests" -Tag "IntegrationTests" { } - It "connects to Azure using a query string" { + It "connects to Azure using a query string" -Skip { # this doesn't work on github, it throws # Method not found: 'Microsoft.Identity.Client.AcquireTokenByUsernamePasswordParameterBuilder' if ($PSVersionTable.PSEdition -eq "Core") { @@ -53,7 +53,7 @@ Describe "Integration Tests" -Tag "IntegrationTests" { } } - It "gets a database from Azure" { + It "gets a database from Azure" -Skip { $PSDefaultParameterValues.Clear() $securestring = ConvertTo-SecureString $env:CLIENTSECRET -AsPlainText -Force $azurecred = New-Object PSCredential -ArgumentList $env:CLIENTID, $securestring