Wdntulk2no-
asked on
Looking to remove SMTP address via command shell
OK here is the deal, i am looking for a SIMPLE command one line to just remove an smtp nothing fancy:
Simply put i want to pick 1 account JDoe and remove an alias that is not his primary with a command line
Simply put i want to pick 1 account JDoe and remove an alias that is not his primary with a command line
Here you go
Get-Mailbox | foreach {
for ($i=$_.EmailAddresses.Coun t;$i -ge 0; $i--)
{
$address = $_.EmailAddresses[$i]
if ($address.SmtpAddress -like "*@target.local" )
{
Write-host("Remove smtp adress: " + $address.AddressString.ToS tring() )
$_.EmailAddresses.RemoveAt ($i)
}
}
$_|set-mailbox
}
Get-Mailbox | foreach {
for ($i=$_.EmailAddresses.Coun
{
$address = $_.EmailAddresses[$i]
if ($address.SmtpAddress -like "*@target.local" )
{
Write-host("Remove smtp adress: " + $address.AddressString.ToS
$_.EmailAddresses.RemoveAt
}
}
$_|set-mailbox
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Unable to verify this solution. I no longer have access to this server so i cannot be fore sure if it would work or not.
Using the Exchange Shell?
set-mailbox "username" -Alias <value>
for the SMTP address, it would depend on what you currently have listed and if you are using x400 addresses still or not. If there are multiple addresses that you want to keep, you'll have to list each one here seperated by commas.
set-mailbox "username" -EmailAddresses {SMTP:email@address}
I don't believe you can do any of this from just the standard command line without calling a script.