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.

Script Repository

Users with upcoming anniversaries

August 22, 2022 Views: 463

The script generates a report containing users whose yearly anniversary is within the specified period. For information on how to create reports, see https://www.adaxes.com/tutorials_ActiveDirectoryManagement_CreateReport.htm.


  • $startDateProperty - Specifies the LDAP name of the property storing the dates to check.
  • $days - Specifies the number of days to check anniversaries for.
Edit Remove
$startDateProperty = "adm-CustomAttributeDate1" # TODO: modify me
$days = 10  # TODO: modify me

$today = [DateTime]::UtcNow

# Add the property to the list of properties to fetch

    $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)
    # Release resources
    if ($searchIterator) { $searchIterator.Dispose() }
Comments 0
Leave a comment

Got questions?

Support Questions & Answers