We have a lot of shared mailboxes in Office 365. Today, I needed to find a subset of those, change their UPN, and set the FirstName and LastName attributes.
I came across this lengthy PowerShell script that someone had created years ago to find users, but the simplest way to do this is via this one line of PowerShell, once you’ve connected to Azure AD:
Get-MsolUser -MaxResults 1000 | Where-Object {($_.ProxyAddresses -like '*texttomatch*')}
An alternative method, if you’re not connected to Azure PowerShell, but are connected to Exchange Online via PowerShell, is to use Get-Mailbox:
Get-Mailbox -ResultSize 1000 | ? {$_.EmailAddresses -like '*texttomatch*'}