The script generates a report that includes licked mailboxes and their master accounts. To execute the script, create a report with the corresponding custom column. The report scope should be set to an OU or container where linked mailboxes are located.
Parameters:
- $masterAccountNameColumndID - Specifies the identifier of the custom column that will store the master account for report items. The column has to be of Active Directory object type. it can be used to group linked mailboxes and their master accounts together. To get the column identifier:
- In the Report-specific columns section, on the Columns tab, right-click the custom column.
- In the context menu, navigate to Copy and click Column ID.
- The column identifier will be copied to clipboard.
- $noMasterAccountGroupName - Specifies the text that will be present in the custom column if a linked mailbox has no master account.
PowerShell
$masterAccountNameColumndID = "{cf958507-8f26-4e77-9072-a6b828a6f956}" # TODO: modify me
$noMasterAccountGroupName = "No master account" # TODO: modify me
$Context.DirectorySearcher.AppendFilter("(&(sAMAccountType=805306368)(msExchRecipientTypeDetails=2))")
$Context.DirectorySearcher.SearchParameters.PropertiesToLoad.Add("msExchMasterAccountSid")
try
{
$searchIterator = $Context.DirectorySearcher.ExecuteSearch()
while ($Context.MoveNext($searchIterator))
{
$searchResult = $searchIterator.Current
# Get Master Account
$sidBytes = $searchResult.GetPropertyByName("msExchMasterAccountSid").Values[0]
$msExchMasterAccountSid = New-Object "Softerra.Adaxes.Adsi.Sid" @($sidBytes, 0)
try
{
$masterAccount = $Context.BindToObject("Adaxes://<SID=$msExchMasterAccountSid>")
}
catch
{
$Context.Items.Add($searchResult, @{ $masterAccountNameColumndID = $noMasterAccountGroupName }, $NULL)
continue
}
$masterAccountDN = $masterAccount.Get("distinguishedName")
$Context.Items.Add($searchResult, @{ $masterAccountNameColumndID = $masterAccountDN }, $NULL)
$Context.Items.Add($masterAccount, @{ $masterAccountNameColumndID = $masterAccountDN }, $NULL)
}
}
finally
{
# Release resources
if ($searchIterator) { $searchIterator.Dispose() }
}