Created
February 22, 2018 09:42
-
-
Save nyanhp/d9a1b591b5a69e300f640d53a02e0b44 to your computer and use it in GitHub Desktop.
Making sense of AD Replication schedules pt 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ADReplicationSchedule | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Parameter(ValueFromPipelineByPropertyName = $true, Mandatory = $true)] | |
[System.DirectoryServices.ActiveDirectory.ActiveDirectorySchedule]$ReplicationSchedule, | |
[Parameter(ValueFromPipelineByPropertyName = $true, Mandatory = $true)] | |
[string]$DistinguishedName | |
) | |
begin | |
{ | |
$returnValues = @() | |
} | |
process | |
{ | |
Write-Verbose -Message ('Processing {0}' -f $DistinguishedName) | |
$returnValue = New-Object PSObject -Property @{ | |
DistinguishedName = $DistinguishedName | |
Schedule = @() | |
} | |
foreach ( $day in [System.Enum]::GetValues([System.DayOfWeek])) | |
{ | |
$scheduleObject = New-Object psobject -Property @{ | |
DayOfWeek = $day | |
Interval = @() | |
} | |
$scheduleObject | Add-Member -MemberType ScriptProperty -Name EnabledInterval -Value { $this.Interval | Where-Object Enabled } | |
$scheduleObject | Add-Member -MemberType ScriptProperty -Name DisabledInterval -Value { $this.Interval | Where-Object Enabled -eq $false } | |
foreach ( $hour in 0..23) | |
{ | |
foreach ( $interval in 0..3) | |
{ | |
$intervalObject = New-Object PSObject -Property @{ | |
IntervalStart = New-TimeSpan -Hours $hour -Minutes ($interval * 14.75) | |
IntervalEnd = New-TimeSpan -Hours $hour -Minutes (($interval + 1) * 14.75) | |
Enabled = $ReplicationSchedule.RawSchedule[[int]$day, $hour, $interval] | |
} | |
$scheduleObject.Interval += $intervalObject | |
} | |
} | |
$returnValue.Schedule += $scheduleObject | |
} | |
$returnValues += $returnValue | |
} | |
end | |
{ | |
$returnValues | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment