This is a PowerShell script to update the replication schedule assigned to a connection object in Active Directory. The script updates the schedule attribute of the object. The schedule attribute is a byte array with one byte for every hour of every day of a week.

The connection objects can be viewed in Active Directory Sites and Services. Intra-site replication is replication between domain controllers within a site. Intra-site connection objects are in the "NTDS Settings" container for each server in the Configuration partition. For example, the distinguished name could be similar to:

cn=<guid>,cn=NTDS Settings,cn=MyServer,cn=Servers,cn=MySite,cn=Sites,cn=Configuration,dc=MyDomain,dc=com

where <guid> is a GUID. Intra-site connection objects created by an administrator will have a name selected by the administrator.

Inter-site replication is replication between sites. The replication schedule is specified in a Site Link object that connects two sites. The Site Link objects will have distinguished names similar to:

cn=SiteA-SiteB,cn=IP,cn=Inter-Site Transports,cn=Sites,cn=Configuration,dc=MyDomain,dc=com

You can view the replication schedule for any connection object in AD Sites and Services. Objects with class NTDS-Connection, NTDS-Site-Settings, or Site-Link will have the schedule attribute.

The SetSchedule.ps1 script supports the parameters in the following table:

Parameter Abbreviation Description
-Site -s Name (RDN) of the Site
-ToServer -t Name (RDN) of the Destination Server
-FromServer -f Name (RDN) of the Source Server
-Name -n Name (RDN) of the inter-site connection object
-DN -d Distinguished Name of the connection object
-CSVFile -c CSV file that specifies the schedule, in local time
-Key -k Switch to display what values mean
-Help -h Switch to display help

The first one or more letters of each parameter can be used as an abbreviation.

To update an intra-site connection object schedule, use the -Site parameter to specify the site name, the -ToServer parameter to specify the NetBIOS name of the destination server, and the -FromServer parameter to specify the source server. Alternatively, you can use the -DN parameter to specify the distinguished name of the connection object. The values for -Site, -ToServer, and -FromServer can be specified in order without the parameter names. For an inter-site connection object, use the -Name parameter to specify the name of the object, or the -DN parameter to specify the distinguished name.

The required CSV file specfies the replication schedule as decimal values for each hour of each day of the week in the local time of the local computer. The CSV must have a header line consisting of the 24 digits, 0 through 23, comma separated, representing the hours in a day. This is followed by 7 lines, for the days Sunday through Saturday. Each of these lines has 24 comma separated decimal values. The table generated by the -Key parameter documents the meaning of the decimal values. The table is shown later, after the examples of usage. The decimal values are needed in the CSV file to specify when replication is scheduled each hour of each day.

Examples of usage:

Use the following statement to update the intra-site replication schedule from ServerC to ServerA in site Site-1.

.\SetSchedule.ps1 Site-1 ServerA ServerC -CSVFile .\Site-1.csv

Example input file (Site-1.csv from above):

0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23
0,1,10,11,0,1,5,15,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
0,2,10,11,0,12,13,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

The first line is a header, specifying the hours in a day, in local time. Next is one line for each day of a week, Sunday through Saturday. The decimal values have the meanings documented in the table displayed when you use the -Key parameter, as shown below.

The following example updates the inter-site replication schedule between Site-A and Site-B. The connection object has the name "SiteA-SiteB".

.\SetSchedule.ps1 -N SiteA-SiteB -CSVFile .\SiteA-SiteB.csv

To output the table of possible values for each hour in the schedule use:

.\SetSchedule.ps1 -k

which results in the following table:

Key to values in the schedule array, one value for each hour of each day
of the week. n = no replication, Y = replication scheduled.
For example, "nnYn" (decimal 4) means replication is scheduled during
the third 15 minute interval after the hour.
                                --- Minutes after hour ---
Decimal  Hex  Binary  Syncs/Hr  00-14  15-29  30-44  45-59 Display
  0      0     0000        0      n      n      n      n     nnnn
  1      1     0001        1      Y      n      n      n     Ynnn
  2      2     0010        1      n      Y      n      n     nYnn
  3      3     0011        2      Y      Y      n      n     YYnn
  4      4     0100        1      n      n      Y      n     nnYn
  5      5     0101        2      Y      n      Y      n     YnYn
  6      6     0110        2      n      Y      Y      n     nYYn
  7      7     0111        3      Y      Y      Y      n     YYYn
  8      8     1000        1      n      n      n      Y     nnnY
  9      9     1001        2      Y      n      n      Y     YnnY
 10      A     1010        2      n      Y      n      Y     nYnY
 11      B     1011        3      Y      Y      n      Y     YYnY
 12      C     1100        2      n      n      Y      Y     nnYY
 13      D     1101        3      Y      n      Y      Y     YnYY
 14      E     1110        3      n      Y      Y      Y     nYYY
 15      F     1111        4      Y      Y      Y      Y     YYYY
Note:
The first bit in each binary value corresponds to the first 15 minute
interval, from 0 to 14 minutes after the hour. The first bit is the
far right hand bit of the binary representation of the value.

SetSchedule.txt <<-- Click here to view or download the program