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
Wdntulk2no-Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sirreal45Commented:
Are you looking to remove the alias or an SMTP address?

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.
0
Ajit663Commented:
Here you go
Get-Mailbox | foreach {
for ($i=$_.EmailAddresses.Count;$i -ge 0; $i--)
{
$address = $_.EmailAddresses[$i]
if ($address.SmtpAddress -like "*@target.local" )
{
Write-host("Remove smtp adress: " + $address.AddressString.ToString() )
$_.EmailAddresses.RemoveAt($i)
}
}
$_|set-mailbox
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Wdntulk2no-Author Commented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.