Skip to content

SqlReplication

dscbot edited this page Oct 26, 2024 · 11 revisions

Parameters

Parameter Attribute DataType Description Allowed Values
InstanceName Key String Specifies the SQL Server instance name where replication distribution will be configured.
Ensure Write String 'Present' will configure replication, 'Absent' will disable (remove) replication. Default value is 'Present'. Present, Absent
DistributorMode Required String 'Local' - Instance will be configured as it's own distributor. 'Remote' - Instance will be configure with remote distributor (remote distributor needs to be already configured for distribution). Local, Remote
AdminLinkCredentials Required PSCredential AdminLink password to be used when setting up publisher distributor relationship.
DistributionDBName Write String Distribution database name. If the parameter DistributionMode is set to 'Local' this will be created, if 'Remote' needs to match distribution database on remote distributor. Default value is 'distributor'.
RemoteDistributor Write String Specifies the SQL Server network name that will be used as distributor for local instance. Required if parameter DistributionMode is set to 'Remote'.
WorkingDirectory Required String Publisher working directory.
UseTrustedConnection Write Boolean Publisher security mode. Default value is $true.
UninstallWithForce Write Boolean Force flag for uninstall procedure. Default values is `$true´.

Description

The SqlReplication DSC resource manages SQL Replication distribution and publishing.

Requirements

  • Target machine must be running Windows Server 2012 or later.
  • Target machine must be running SQL Server 2012 or later.
  • When using the resource against an SQL Server 2022 instance, the module SqlServer v22.0.49-preview or newer must be installed.

Known issues

All issues are not listed here, see here for all open issues.

Examples

Example 1

This example shows how to configure a SQL Server instance as the distributor.

Configuration Example
{
    param
    (
        [Parameter(Mandatory = $true)]
        [System.Management.Automation.PSCredential]
        $SqlAdministratorCredential
    )

    Import-DscResource -ModuleName 'SqlServerDsc'

    node localhost
    {
        SqlReplication 'distributor'
        {
            Ensure               = 'Present'
            InstanceName         = 'DISTRIBUTOR' # Or 'MSSQLSERVER' for default instance.
            AdminLinkCredentials = $SqlAdministratorCredential
            DistributorMode      = 'Local'
            DistributionDBName   = 'MyDistribution'
            WorkingDirectory     = 'C:\Temp'

            PsDscRunAsCredential = $SqlAdministratorCredential
        }
    }
}

Example 2

This example shows how to configure a SQL Server instance as the publisher.

Configuration Example
{
    param
    (
        [Parameter(Mandatory = $true)]
        [System.Management.Automation.PSCredential]
        $SqlAdministratorCredential
    )

    Import-DscResource -ModuleName 'SqlServerDsc'

    node localhost
    {
        SqlReplication 'publisher'
        {
            Ensure               = 'Present'
            InstanceName         = 'PUBLISHER' # Or 'MSSQLSERVER' for default instance.
            AdminLinkCredentials = $SqlAdministratorCredential
            DistributorMode      = 'Remote'
            DistributionDBName   = 'MyDistribution'
            RemoteDistributor    = 'distsqlsrv.company.local\DISTRIBUTOR'
            WorkingDirectory     = 'C:\Temp'

            PsDscRunAsCredential = $SqlAdministratorCredential
        }
    }
}

Home

Commands

Resources

Usage

Clone this wiki locally