How to remove an email alias/address from office 365 user when user no longer has exchange online license

Mohammad Reza Hosseinian 5 Reputation points
2024-07-11T06:43:35.6566667+00:00

We want to transfer our domain to another Tenant. in the old Tenant there are no subscriptions so i can no longer edit the users email aliases ( it states "this user doesn't have an Exchange online license ) and as such cannot remove our public domain from office 365

I have tried the following script: (THIS ARTICLE)

$Records = Get-mailbox -ResultSize Unlimited| where {$.emailaddresses -like "smtp:*@domain.com"} | Select-Object DisplayName,@{Name=“EmailAddresses”;Expression={$.EmailAddresses |Where-Object {$_ -like “smtp:*domain.com”}}}   foreach ($record in $Records) {     write-host "Removing Alias" $record.EmailAddresses "for" $record.DisplayName     Set-Mailbox $record.DisplayName -EmailAddresses @{Remove=$record.EmailAddresses} }

but it does not do anything. in powershell it says:

Set-Mailbox: Ex6F9304|Microsoft.Exchange.Configuration.Tasks.ManagementObjectNotFoundException|The operation could not be performed

because the object '' was not found on '**.PROD.OUTLOOK.COM'.

Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
4,949 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.