1
votes

I need a PowerShell script to sync between an Azure SQL Database and a SQL Server on-premises database. I have gone through this link (https://docs.microsoft.com/en-us/azure/azure-sql/database/scripts/sql-data-sync-sync-data-between-azure-onprem) and I was able to generate Sync Agent, Sync Group, Sync member. Now I'm getting an error like below: enter image description here

the powershell code is as below

using namespace Microsoft.Azure.Commands.Sql.DataSync.Model
using namespace System.Collections.Generic
    Write-Host "Adding tables and columns to the sync schema..."
    $databaseSchema = Get-AzSqlSyncSchema -ResourceGroupName "myresource" -ServerName "myservername" `
        -DatabaseName "mydatabase" -SyncGroupName "TestSync" `
    $databaseSchema | ConvertTo-Json -depth 5 -Compress | Out-File "syncSchema.json"
    $newSchema = [AzureSqlSyncGroupModel]::new() 
    $newSchema.Tables = [List[AzureSqlSyncGroupSchemaTableModel]]::new();
Here is a similar answer from me.KrishnaG-MSFT