Script repository
The script generates a report containing users whose yearly anniversary is within the specified period. To execute the script, create a report with a scope.
Parameters
$startDateProperty- the name of the property storing the dates to check.$days- the number of days to check anniversaries for.
$startDateProperty = "adm-CustomAttributeDate1" # TODO: modify me
$days = 10 # TODO: modify me
$today = [DateTime]::UtcNow
# Add the property to the list of properties to fetch
$Context.DirectorySearcher.SearchParameters.PropertiesToLoad.Add($startDateProperty)
try
{
$searchIterator = $Context.DirectorySearcher.ExecuteSearch()
while ($Context.MoveNext($searchIterator))
{
$searchResult = $searchIterator.Current
$startDate = $searchResult.GetPropertyByName($startDateProperty).Values[0]
$result = $startDate.DayOfYear - $today.DayOfYear
if ($result -le $days -and $result -gt 0)
{
$Context.Items.Add($searchResult)
}
}
}
finally
{
# Release resources
if ($searchIterator) { $searchIterator.Dispose() }
}
Comments 0
You must be signed in to comment.