commands

^

Add-DbaReplArticle

Author Jess Pomfret (@jpomfret), jesspomfret.com
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Add-DbaReplArticle on GitHub.
Want to see the Bill Of Health for this command? Check out Add-DbaReplArticle.

Synopsis

Add an article configuration to a publication in a database on the SQL Server instance(s).

Description

Add an article configuration to a publication in a database on the SQL Server instance(s).

Syntax

Add-DbaReplArticle
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [-Database] <String>
    [-Publication] <String>
    [[-Schema] <String>]
    [-Name] <String>
    [[-Filter] <String>]
    [[-CreationScriptOptions] <PSObject>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Add-DbaReplArticle -SqlInstance mssql1 -Database Northwind -Publication PubFromPosh -Name TableToRepl

Adds the TableToRepl table to the PubFromPosh publication from mssql1.Northwind

Example: 2
PS C:\> $article = @{
>> SqlInstance           = "mssql1"
>> Database              = "pubs"
>> Publication           = "testPub"
>> Name                  = "publishers"
>> Filter                = "city = 'seattle'"
>> }
PS C:\> Add-DbaReplArticle @article -EnableException

Adds the publishers table to the TestPub publication from mssql1.Pubs with a horizontal filter of only rows where city = 'seattle.

Example: 3
PS C:\> $cso = New-DbaReplCreationScriptOptions -Options NonClusteredIndexes, Statistics
PS C:\> $article = @{
>> SqlInstance           = 'mssql1'
>> Database              = 'pubs'
>> Publication           = 'testPub'
>> Name                  = 'stores'
>> CreationScriptOptions = $cso
>> }
PS C:\> Add-DbaReplArticle @article -EnableException

Adds the stores table to the testPub publication from mssql1.pubs with the NonClusteredIndexes and Statistics options set
includes default options.

Required Parameters

-SqlInstance

The SQL Server instance(s) for the publication.

Alias
Required True
Pipeline true (ByValue)
Default Value
-Database

The publication database to apply the article configuration to be replicated.

Alias
Required True
Pipeline false
Default Value
-Publication

The name of the publication.

Alias
Required True
Pipeline false
Default Value
-Name

The name of the object to add as an article.

Alias
Required True
Pipeline false
Default Value

Optional Parameters

-SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential). Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported. For MFA support, please use Connect-DbaInstance.

Alias
Required False
Pipeline false
Default Value
-Schema

Schema where the article to be added is found. Default is dbo.

Alias
Required False
Pipeline false
Default Value dbo
-Filter

Sets the where clause used to filter the article horizontally, e.g., DiscontinuedDate IS NULL E.g. City = 'Seattle'

Alias
Required False
Pipeline false
Default Value
-CreationScriptOptions

Options for the creation script. Use New-DbaReplCreationScriptOptions to create this object.

Alias
Required False
Pipeline false
Default Value
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting. Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False
-WhatIf

If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.

Alias cf
Required False
Pipeline false
Default Value