Working on a project where we needed to automated the mail-enabling of mailusers. I also need to create a csv file after the fact that kicks out those new mail enabled objects with their LegacyExchangeDN value.
So I setup this query to get all the valid mailusers that need to be mailenabled. Valid meaning they have the targetaddress attribute set. Need to be mail enabled because they do not have a legacyexchangedn value.
This works except for one issue. Some of the accounts have a leading or trailing whitespace in their display name. That is being addressed. But in the meantime I need to put some code together that detects the error state and doesn't include those users in the $users variable. So I can later use that variable to create the csv file. Thoughts?
$users = Get-mailuser -ResultSize unlimited -OrganizationalUnit "domain.COM/Accounts/Users" `
-Filter {ExternalEmailAddress -ne $null} | ?{$_.legacyexchangeDN -eq ""}
Jeff C