forked from mubix/PowerShell-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Script-Replication.ps1
31 lines (21 loc) · 982 Bytes
/
Script-Replication.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServr.Rmo")
$servername = "STGSQL610"
$repserver = New-Object "Microsoft.SqlServer.Replication.ReplicationServer"
$srv = New-Object "Microsoft.SqlServer.Management.Common.ServerConnection" $servername
$srv.connect()
$repserver.ConnectionContext = $srv
$databasename = "Boeing4"
$repdb = $repserver.ReplicationDatabases[$databasename]
$repdb.transpublications
$publication_name = "BoeingSMC"
$publication_object = $repdb.transpublications[$publication_name]
$publication_object.TransArticles
$publication_object.TransSubscriptions
$script_val = [Microsoft.SqlServer.Replication.ScriptOptions]::Creation -bxor [Microsoft.SqlServer.Replication.ScriptOptions]::IncludeGo
$publication_object.Script($script_val)
Foreach ($article in $publication_object.TransArticles) {
$article.Script($script_val)
}
Foreach ($subscription in $publication_object.TransSubscriptions) {
$subscription.Script($script_val)
}