In C#, I am trying to get the the property on the Exchange mailbox of a user, "EmailAddresses" using powershell 2010. Previously I had code that did it for Powershell 1.0 but it seems that the type of the results returned from the get-mailbox command has changed with regard to this property.
for powershell 1.0, this used to work.
emailaddresses = ps.Members["EmailAddresses"].Value as Microsoft.Exchange.Data.ProxyAddressCollection;
Now however, it complains that
ps.Members["EmailAddresses"].Value is a PSMemberInfo.Value
OK, I can grab the string from it using this
ps.Members["EmailAddresses"].Value.ToString();
but I still need the type ProxyAddress for the code varaible emailaddresses.
ProxyAddress() constructo is protected and I can't see to cast it from string to type ProxyAddress.
I saw in a code sample: http://social.msdn.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/593e0793-2485-431a-a923-c5acf53bd65a/ where Mangia did this:
Microsoft.Exchange.Data.ProxyAddress externalemailaddr = new Microsoft.Exchange.Data.SmtpProxyAddress(emailmail, true);
Can someone give me pointers to the derived classes of ProxyAddress?
I have searched on the web without success.
Is there a way to construct a new ProxyAddress from a string?
I have to put all the email addresses in the string into a ProxyAddressCollection to make it work again.
Any help or references would be greatly appreciated. This is powershell 2 and Exchange 2010
Thanks in advance.