Skip to content

Instantly share code, notes, and snippets.

@jonathonolson
Created July 31, 2019 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathonolson/ad9d0b7f99a778255399e28104b7c0f5 to your computer and use it in GitHub Desktop.
Save jonathonolson/ad9d0b7f99a778255399e28104b7c0f5 to your computer and use it in GitHub Desktop.
RemoveX500
$users = import-csv ~\Documents\FirstBatch.csv
foreach ($u in $users) {
$mb = get-mailbox ($u.primarysmtpaddress)
$x500 = $mb.EmailAddresses | where {$_.prefix -like "X500"}
$x500 | select -ExpandProperty proxyaddressstring | Out-File C:\Users\dds\Documents\x500.txt -Append
#Write-Output "Before:"
#$mb.EmailAddresses
$remove = $x500 | select -ExpandProperty proxyaddressstring
#$remove = ($mb.Alias)+"@local"
$remove
$mb | Set-Mailbox -EmailAddresses @{remove = "$remove"}
Write-Output "After:"
$mb.EmailAddresses
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment