Author Posts

April 16, 2014 at 7:38 pm

I am running a Powershell script that contains Exchange Shell cmdlets.

I followed the instructions here to setup a remote connection to Exchange Shell.

However, the created connection appears to only return output for only the first command.

My simple test script :

Get-TransportConfig | Select Identity, MaxRecipientEnvelopeLimit
Get-TransportConfig | Select Identity, MaxReceiveSize

Only the first command regarding MaxRecipientEnvelopeLimit returns a value. The next command does not return anything. When I switch the commands around, the same happens, only the 1st command runs.

Any help is appreciated.

April 17, 2014 at 2:22 am

Hi,

Maybe you nede to post the contents of your function. Hard to help without it

Cherrie

Tore

April 17, 2014 at 6:54 am

There are some known problems I've heard of regarding Exchange and implicit remoting. I'll see if I can point someone to look at this, who might have more experience.

April 17, 2014 at 7:55 am

I can confirm this is an issue, although I can't explain it. I ran the commands directly on a server with Exchange 2010 SP3 to eliminate any remoting issues. Server is running Windows Server 2008 R2 with SP1. PowerShell version is 2.

Example of Reported Issue

µ

April 17, 2014 at 8:02 am

@Tore Groneng: My script has no functions, it is exactly what I have quoted in my 1st post 🙂

@Don Jones: Thanks for the help.

@mike F Robbins: Yes, you hit it spot on, this is what I get as well. I am running Exchange 2013 on Server 2012. Powershell Version 3. So apparently the issue persists in later versions..

Interestingly, if I try another set of Exchange cmdlets, it works to a certain extent. Take for example,

Get-RemoteDomain | select identity, DeliveryReportEnabled
Get-PopSettings | fl -property LoginType

It outputs perfectly fine. But when rearrange the positioning and add in other cmdlets, everything goes awry again.

April 17, 2014 at 8:03 am

Jut saw that Rob Campbell (@mjolinor) posted on twitter that it's an issue with the default formatting. Piping it to Format-List shows the properties:

µ

April 17, 2014 at 8:25 am

It's because the first command sets the pipeline up for only the Identity and MaxRecipientEnvelopeLimit properties. When the second command runs, the pipeline doesn't know anything about the MaxReceiveSize property so only the Identity property results are displayed for that command (the second one). You could jam any two commands together and have the same issue.

Notice the handles property doesn't show up in the results of this script and the second row for the id property is blank:

µ

April 17, 2014 at 8:38 am

Here's a good old article from Jeffrey Snover himself that explains why this is:

April 17, 2014 at 8:38 am

Um, OK. Here's the link:

April 18, 2014 at 1:30 am

@jeffrey Smith : Thanks for the link, will try to digest it.

@mike F Robbins : Thanks for the explanation. But now I ran into another problem.

Format-List will conflict with some of the cmdlets that already use Format-List. Output formatting is hard to handle properly =/

For instance, this script will not work when I execute it with Format-List. ( ./script1 | fl )
It will spew errors.

"Maximum size of received emails : \r\n"
Get-TransportConfig | Select Identity, MaxReceiveSize 
"\r\n"

"Password Policy Settings : \r\n"
Get-ActiveSyncMailboxPolicy |  fl -property DevicePasswordHistory
Get-ActiveSyncMailboxPolicy |  fl -property DevicePasswordExpiration
"\r\n"

note: I have replaced the escape character with a \ instead.

April 18, 2014 at 2:18 am

Okay I sort of solved it, although I am not sure if this is the right method.

I piped the cmdlets to "Select" instead of "Format-List", and it worked.