Need help completing this Powershell script with some Exchange 2010 commands.
Posted
by
Pure.Krome
on Server Fault
See other posts from Server Fault
or by Pure.Krome
Published on 2011-01-13T04:48:55Z
Indexed on
2011/01/13
4:55 UTC
Read the original article
Hit count: 339
powershell
|exchange-2010
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?
© Server Fault or respective owner