EmailAddresses displayed as strings when connecting using the New-PSSession command


When connecting using the Exchange Management Shell, the command (Get-Mailbox –Identity Administrator).EmailAddresses displays a result similar to:

AddressString      : C=GB;A= ;P=ZONE LTD;O=Exchange;S=Administrator;G=Zone;
ProxyAddressString : X400:C=GB;A= ;P=ZONE LTD;O=Exchange;S=Administrator;G=Zone;
Prefix             : X400
IsPrimaryAddress   : True
PrefixString       : X400

AddressString      : C=GB;A= ;P=ZONE LTD;O=Exchange;S=Administrator;
ProxyAddressString : x400:C=GB;A= ;P=ZONE LTD;O=Exchange;S=Administrator;
Prefix             : X400
IsPrimaryAddress   : False
PrefixString       : x400

SmtpAddress        : Administrator@zone.lab
AddressString      : Administrator@zone.lab
ProxyAddressString : SMTP:Administrator@zone.lab
Prefix             : SMTP
IsPrimaryAddress   : True
PrefixString       : SMTP

SmtpAddress        : postmaster@zone.lab
AddressString      : postmaster@zone.lab
ProxyAddressString : smtp:postmaster@zone.lab
Prefix             : SMTP
IsPrimaryAddress   : False
PrefixString       : smtp

When connecting using a new PSSession on a machine on which the Exchange management tools aren’t installed, the result is the following:

Connect commands:

$global:ExchangePSSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$ExchangeServer/PowerShell/?SerializationLevel=Full -Authentication Kerberos
Import-PSSession $ExchangePSSession | Out-Null

Result:

X400:C=GB;A= ;P=ZONE LTD;O=Exchange;S=Administrator;G=Zone;
x400:C=GB;A= ;P=ZONE LTD;O=Exchange;S=Administrator;
Administrator@zone.lab
postmaster@zone.lab

 

The behaviour is by design and a result of communicating across http/soap. Most objects are deserialized on the wire which means that the client will only receive a text representation of the original server side object.

 

The Powershell team wrote a blog entry that explains how objects are passed across the wire. It also explains which objects can be rehydrated on the client side. As the data types don’t exist on the client side, no Exchange objects can be rehydrated.

http://blogs.msdn.com/b/powershell/archive/2010/01/07/how-objects-are-sent-to-and-from-remote-sessions.aspx

 

The only way to get this working is to install the management tools. The Exchange Management tools use the following logic:

  1. Import Exchange data types
  2. Creation of the PS session
  3. Export the PS session as a module
  4. Import the module
  5. Import PS session
Comments (0)

Skip to main content