I am working on a migration from on premise Exchange 2010/2013 to Office 365 Exchange online. I am trying to collect a report of all mailboxes of user type and shared type that has send as permissions granted; as well as the names of the mail users that have been granted the permission. The code I am using is as follows.
#Get-Mailbox -RecipientTypeDetails SharedMailbox,usermailbox -resultsize unlimited | Get-ADPermission | where {($_.ExtendedRights -like "*Send-As*") -and ($_.IsInherited -eq $false) -and -not (($_.User -like "NT AUTHORITY\SELF") -or ($_.User -like "S-1-5-*") -or ($_.User -like "NT AUTHORITY\SYSTEM") -or ($_.User -like "BUILTIN\Administrators"))} | select User,identity | Export-Csv $outfile
The code seems to work but after a few minutes I get the following:
I have tried running the code from 3 different exchange servers and keep getting a variation of the same error and am at a loss. I have even tried limiting it to just users and just shared mailboxes to no avail. Any suggestions would be appreciated.