{"id":8486,"date":"2024-12-21T23:05:32","date_gmt":"2024-12-21T23:05:32","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=8486"},"modified":"2024-12-21T23:05:33","modified_gmt":"2024-12-21T23:05:33","slug":"bulk-remove-cloud-only-proxy-address-from-users-mailboxes-in-365-in-powershell","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/bulk-remove-cloud-only-proxy-address-from-users-mailboxes-in-365-in-powershell","title":{"rendered":"Bulk Remove Cloud Only Proxy Address from Users Mailboxes in 365 in Powershell"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code class=\"\">Connect-ExchangeOnline\n# Define the domain to remove\n$domainToRemove = \"domain.com.au\"\n\n# Get all mailboxes\n$mailboxes = Get-Mailbox -ResultSize Unlimited\n\nforeach ($mailbox in $mailboxes) {\n    # Get current email addresses\n    $currentAddresses = $mailbox.EmailAddresses\n\n    # Filter out addresses with the specified domain\n    $updatedAddresses = $currentAddresses | Where-Object { $_ -notlike \"*@$domainToRemove\" }\n\n    # Update the mailbox if any addresses were removed\n    if ($currentAddresses.Count -ne $updatedAddresses.Count) {\n        Write-Host \"Updating mailbox for: $($mailbox.PrimarySmtpAddress)\"\n#Fixes WARNING: Proxy address  is used as WindowsLiveId. So it can't be removed from list of email addresses. To remove it, first change\nthe WindowsLiveId.\n\t\tSet-Mailbox -Identity $mailbox.PrimarySmtpAddress -MicrosoftOnlineServicesID $mailbox.PrimarySmtpAddress\n        Set-Mailbox -Identity $mailbox.Identity -EmailAddresses $updatedAddresses\n\n    } else {\n       # Write-Host \"No changes needed for: $($mailbox.PrimarySmtpAddress)\"\n    }\n}\n\nWrite-Host \"Completed processing all users.\"\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8486","post","type-post","status-publish","format-standard","hentry","category-research"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/8486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=8486"}],"version-history":[{"count":1,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/8486\/revisions"}],"predecessor-version":[{"id":8487,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/8486\/revisions\/8487"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=8486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=8486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=8486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}