Need help completing this Powershell script with some Exchange 2010 commands.
- by Pure.Krome
Hi folks.
the following powershell script lists all the email aliases I have for a single mailbox.
>$mbx = Get-Mailbox myuser
>$mbx.EmailAddresses
and that lists all the addresses. eg.
SmtpAddress : atari@foo.com
AddressString : atari@foo.com
ProxyAddressString : smtp:atari@foo.com
Prefix : SMTP
IsPrimaryAddress : False
PrefixString : smtp
SmtpAddress : info@foo.com
AddressString : info@foo.com
ProxyAddressString : smtp:info@foo.com
Prefix : SMTP
IsPrimaryAddress : False
PrefixString : smtp
SmtpAddress : me@foo.com
AddressString : me@foo.com
ProxyAddressString : SMTP:justin@foo.com
Prefix : SMTP
IsPrimaryAddress : True
PrefixString : SMTP
Now to add a new email address, I do the following poweshell command :-
$mbx.EmailAddresses += "myEmailAddress.com"
$mbx | Set-Mailbox
So i'm not sure how i can use the foreach to remove each address?
I tried:-
@mbx.EmailAddresses | foreach { $mbx.EmailAddresses -= $._SmtpAddress }
and that failed miserably. That's my first attempt of PS script, ever :P
Can anyone help?