I need to get information about public folders from a remote Exchange server and for this I use remote powershell. But there is one problem - remote powershell reduces all properties of returned objects to a string form:

$mailFolders = Invoke-Command -ConnectionUri:$uri –ConfigurationName Microsoft.Exchange -Credential:$creds -ScriptBlock { Get-MailPublicFolder "\imdev-ie-025-pf1\sublevel1\sublevel2"; }; $mailFolders | Select -ExpandProperty EmailAddresses 

This code will return the following:

 smtp:sublevel2@imdev-ie-025-2.com smtp:sublevel2@imdev-ie-025.com 

But if you run this cmdlet locally on the exchange server, the result will be something like this:

 Get-MailPublicFolder "\imdev-ie-025-pf1\sublevel1\sublevel2" | Select -ExpandProperty EmailAddresses SmtpAddress : sublevel2@imdev-ie-025-2.com AddressString : sublevel2@imdev-ie-025-2.com ProxyAddressString : smtp:sublevel2@imdev-ie-025-2.com Prefix : SMTP IsPrimaryAddress : False PrefixString : smtp SmtpAddress : sublevel2@imdev-ie-025.com AddressString : sublevel2@imdev-ie-025.com ProxyAddressString : smtp:sublevel2@imdev-ie-025.com Prefix : SMTP IsPrimaryAddress : False PrefixString : smtp 

Are there any ideas how to get objects with all values? Thank.

  • try using select in one -scriptBlock, there is a possibility that it receives an object with properties, but it does not send properties, and therefore, after receiving the result, it only works on the headers $ mailFolders = Invoke-Command -ConnectionUri: $ uri –ConfigurationName Microsoft.Exchange -Credential: $ creds -ScriptBlock {Get-MailPublicFolder "\ imdev-ie-025-pf1 \ sublevel1 \ sublevel2" | Select -ExpandProperty EmailAddresses; }; - Paulo Berezini
  • @ paulo-berezini did just that. First I get a collection of all public folders, then for everyone I get EmailAddresses. The disadvantage of this approach is that for each folder you need to make a new challenge. Why Remote Powershell serializes only to one level of nesting, I never figured it out. Perhaps this is somehow customizable. - Ilya Edrets
  • I think this is not configurable, this is how powershell works, in any case, you should contact those support on this issue - Paulo Berezini

0