Create EWS Mailbox list via PowerShell
Description
When creating a list of EWS users via Discovery Attender Settings->EWS Options->PowerShell->Export, the list may not be created, or another error may be encountered. The PowerShell button on the EWS Mailbox selection screen (see screenshot below) is populated by a .dat file created (usually) in the Settings. However, sometimes the creation of this list cannot be accomplished within the settings. PowerShell can be used to create this list.
The PowerShell command to create the file is as follows in version DA 4.0 or higher:
get-mailbox -ResultSize unlimited | fl RunspaceId,UserPrincipalName,PrimarySmtpAddress,DisplayName,WindowsEmailAddress > EWSAccounts.dat
Note: If you would like to filter by department, the following command should work
Get-Recipient -ResultSize Unlimited -RecipientType UserMailbox -Filter {department -eq "DepartmentName"} | Get-Mailbox | fl RunspaceId,UserPrincipalName,PrimarySmtpAddress,DisplayName,WindowsEmailAddress > EWSAccounts.dat
Note:
If you are having trouble exporting the list of mailboxes, please check these areas before attempting this PowerShell Command.
Azure permissions
Confirm these permissions are configured as specified in the Discovery Attender Getting Started Guide
Confirm modern authentication is correctly configured for Discovery Attender
Default value for EWS List is incorrect (only applies to Discovery Attender version 4.3)