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: 299
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 : [email protected]
AddressString : [email protected]
ProxyAddressString : smtp:[email protected]
Prefix : SMTP
IsPrimaryAddress : False
PrefixString : smtp
SmtpAddress : [email protected]
AddressString : [email protected]
ProxyAddressString : smtp:[email protected]
Prefix : SMTP
IsPrimaryAddress : False
PrefixString : smtp
SmtpAddress : [email protected]
AddressString : [email protected]
ProxyAddressString : SMTP:[email protected]
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