Created
July 31, 2019 14:38
-
-
Save jonathonolson/ad9d0b7f99a778255399e28104b7c0f5 to your computer and use it in GitHub Desktop.
RemoveX500
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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