Skip to content

Add-DbaAgDatabase - Conversion error  #5742

Closed
@brunobbc

Description

Environmental information

SQL Server:

sql Microsoft SQL Server 2016 (SP2) (KB4052908) - 13.0.5026.0 (X64) Mar 18 2018 09:11:49 Copyright (c) Microsoft Corporation Developer Edition (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) (Hypervisor)
/* REPLACE WITH output of @@Version */


### Report

<!--
Things to consider:
- Conversions errors when try to run ADD-DbaAGDatabase
--> 

#### Errors Received

<!-- 
WARNING: [17:44:39][Add-DbaAgDatabase] Failure | Cannot convert the "[SVR2]" value of type
"Microsoft.SqlServer.Management.Smo.Server" to type "Microsoft.SqlServer.Management.Smo.Server".
Fin du script : 2019-06-13 5:44:39 PM

-->

#### Steps to Reproduce

<!--
$InstanceName = $env:computername
$AvailabilityGroup = Get-DbaAvailabilityGroup -SqlInstance $InstanceName | select -ExpandProperty Name
$PrimaryServer = "SVR1"
$SecondaryServer = "SVR2"
$Database = "Test"
$SharedPath = "\\" + $PrimaryServer + "\E$\MSSQL\Backup"

$DatabaseBackupFile = $SharedPath + "\" + $Database + ".bak"
$LogBackupFile = $SharedPath + "\" + $Database + ".trn"

Backup-SqlDatabase -Database $Database -BackupFile $DatabaseBackupFile -ServerInstance $PrimaryServer -Verbose
Backup-SqlDatabase -Database $Database -BackupFile $LogBackupFile -ServerInstance $PrimaryServer -BackupAction Log -Verbose

Restore-SqlDatabase -Database $Database -BackupFile $DatabaseBackupFile -ServerInstance $SecondaryServer -NoRecovery -Verbose 
Restore-SqlDatabase -Database $Database -BackupFile $LogBackupFile -ServerInstance $SecondaryServer -RestoreAction Log -NoRecovery -Verbose

Add-DbaAgDatabase -AvailabilityGroup $AvailabilityGroup -Database $Database -Secondary $SecondaryServer -SharedPath $SharedPath -SqlInstance $PrimaryServer -UseLastBackup
-->

#### Expected Behavior

<!--
I expect to have a DB syncronized and added to the secondary.
-->

#### Actual Behavior

<!--
Primary Server = DB is in sycronized State and availability Database is created (Correct !!)
Secondary = DB is in restoring state and availability Database is created  with error. 
-->

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions