Get-ReplScript
Calls Script Method on RMO objects including ReplicationServer, Publication, Subscription and Articles.
Syntax
Get-ReplScript [-rmo] <Object> [[-scriptOpts] <Object>] [<CommonParameters>]
Detailed Description
The Get-ReplScript function calls the Script Method for RMO object that support the method including ReplicationServer, Publication, Subscription and Articles.
Related Commands
Parameters
Name |
Description |
Required? |
Pipeline Input |
Default Value |
rmo |
|
true |
true (ByValue) |
|
scriptOpts |
|
false |
false |
|
Input Type
Microsoft.SqlServer.Replication.*
You can pipe rmo objects to Get-ReplScript that support the Script method
Return Values
System.String
Get-ReplScript returns an array of System.String objects
Notes
Validation that the object piped is in the namespace Microsoft.SqlServer.Replication is performed.
Examples
EXAMPLE 1
Get-ReplServer "Z002\sql2K8" | Get-replscript
This command scripts out the replication server settings for SQL Server Z002\sql2K8.
EXAMPLE 2
$scriptOpts = New-ReplScriptOptions; $scriptOpts.Deletion = $true; Get-ReplServer "Z002\sql2K8" | Get-replscript -scriptOpts $scriptOpts
This command creates an RMO Scriptoptions object, sets the Deletion property to true and finally calls Get-replscript passing the script options.
EXAMPLE 3
Get-ReplPublication 'Z002\Sql2k8' | Get-ReplScript
This command scripts out the publications for SQL Server Z002\sql2K8.
EXAMPLE 4
Get-ReplPublication 'Z002\Sql2k8' | Get-ReplSubscription | Get-ReplScript
This command scripts out the subscriptions for SQL Server Z002\sql2K8.
EXAMPLE 5
Get-ReplPublication 'Z002\Sql2k8' | Get-ReplArticle | Get-ReplScript
This command scripts out the articles for SQL Server Z002\sql2K8.