Creating a persistent remote Exchange Shell session.

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.


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



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.

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


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

@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.

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:


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:


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

Um, OK. Here’s the link:

OK, I obviously have no idea how to use the markup here to add a link:

@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 

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

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

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.