Script repository
The script creates a CSV-formatted report on delegates of mailboxes in all domains managed by Adaxes. To execute the script, create a scheduled task configured for the Domain object type and add a managed domain to the Activity Scope of the task. The domain will only be used to trigger execution of the scheduled task.
In the script, the $csvFilePath variable specifies a path to the CSV file to be created.
$csvFilePath = "\ServerShareMailboxDelegates.csv" # TODO: modify me
function SearchObjects($criteria, $properties)
{
$searcher = $Context.BindToObject("Adaxes://rootDSE")
$searcher.Criteria = $criteria
$searcher.SearchScope = "ADS_SCOPE_SUBTREE"
$searcher.PageSize = 500
$searcher.ReferralChasing = "ADS_CHASE_REFERRALS_NEVER"
$searcher.SetPropertiesToLoad($properties)
$searcher.VirtualRoot = $True
try
{
$searchResultIterator = $searcher.ExecuteSearch()
$searchResults = $searchResultIterator.FetchAll()
return ,$searchResults
}
finally
{
# Release resources
if ($searchResultIterator){ $searchResultIterator.Dispose() }
}
}
# Search mailbox
$criteria = New-AdmCriteria "user" -Expression {publicDelegates -empty $False}
$searchResults = SearchObjects $criteria @("publicDelegates")
# Build report
$report = New-Object System.Collections.ArrayList
foreach ($searchResult in $searchResults)
{
# Get mailbox name.
$mailboxDisplayName = $Context.GetDisplayNameFromAdsPath($searchResult.AdsPath)
$publicDelegates = $searchResult.Properties["publicDelegates"].Values
for ($i = 0; $i -lt $publicDelegates.Count; $i++)
{
# Get object name.
$displayName = $Context.GetDisplayNameFromAdsPath("Adaxes://$($publicDelegates[$i])")
# Build record
$record = New-Object PSObject
$record | Add-Member -Membertype NoteProperty -Name "Mailbox name" -Value $mailboxDisplayName
$record | Add-Member -Membertype NoteProperty -Name "ResourceDelegates" -Value $displayName
# Add record to the report
$report.Add($record)
}
}
# Export to CSV file
$report | Export-Csv $csvFilePath -NoTypeInformation
Comments 2
You must be signed in to comment.
Ray Bilyk
Will this work with mailboxes in Exchange Online?
Support
Hello Ray,
No, the script will not work for pure Exchange Online mailboxes. Unfortunately, there is no easy way to do that.