Script repository

Users with upcoming anniversaries

Updated on: Jan 18, 2026, Views: 4243

Reports

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.

    Got questions?

    Support Questions & Answers

    We use cookies to improve your experience.
    By your continued use of this site you accept such use.
    For more details please see our privacy policy and cookies policy.