Get-moverequest / Get-moverequeststatistics: Pipeline not executed because a pipeline is already executing

Hello,
I need to clarify, why
Get-MoveRequest | select -ExpandProperty name |%{Get-MoveRequestStatistics $_}  complains about pipelines

Ofc i can do this like this way:

$requests = Get-MoveRequest
foreach ($req in $requests) {Get-MoveRequestStatistics $req}

Im not really understanding it, because i use the oneliner syntax a lot and usually without problem
fe: get-aduser -filter * -SearchBase "ou=users,dc=contoso,dc=com" |%{get-mailbox $_.name}

Thank you

February 24th, 2015 8:42am

Hi,

What version of Exchange? I run into this with Exchange 2010 quite often and find myself needing to use foreach loops instead of ForEach-Object.

Free Windows Admin Tool Kit Click here and download it now
February 24th, 2015 8:48am

Exch 2k10 SP3 RU6 (i think)
February 24th, 2015 9:00am

Exch 2k10 SP3 RU6 (i think)

Yep, we're at the same level.

I haven't found a way around this, nor do I have an explanation for why it happens.

Free Windows Admin Tool Kit Click here and download it now
February 24th, 2015 9:12am

Hi,

this is due to the Pipeline Architecture versus Remote-Session Control. Even when you run the Exchange Shell locally on the Exchange Server, it creates a remote session.

When you use the Foreach-Object cmdlet, it runs the Script-Block in its Process-Block. Which means, multiple instances may be run in parallel if the script block takes its time (which it inevitably does in a session). This means that multiple Get-MoveRequestStatistics will run in parallel, and since you run it without a pipeline each time, its Begin-Block fires each time.

Now check out this command:

Get-Command Get-MoveRequestStatistics | Select -ExpandProperty Definition

As you can see, the Get-MoveRequestStatistics-Function is actually little more than a wrapper that opens a pipeline on the remote session, then passes the input through it. You simply hit the session limits by running it like this.

Why not use the function like this though:

Get-MoveRequest | Get-MoveRequestStatistics

That way you only call the Begin-Block of Get-MoveRequestStatistics once and should be fine. (Don't know whether that works fine - don't have any pending moves right now - but generally that works fine for Exchange functions ...

Cheers,
Fred

February 24th, 2015 9:26am

Thanks Fred.
Free Windows Admin Tool Kit Click here and download it now
February 24th, 2015 9:30am

http://mikepfeiffer.net/2010/02/exchange-management-shell-error-pipelines-cannot-be-executed-concurrently/

So, saving get-moverequest result into variable also works.

$requests |%{Get-MoveRequestStatistics $_ |select message}

Did u ever encounter a problem when u cannot move mailbox to another database?

Message
-------
Error: MapiExceptionNoAccess: Unable to query table rows. (hr=0x80070005, ec=-2147024891)...
Error: MapiExceptionNoAccess: Unable to query table rows. (hr=0x80070005, ec=-2147024891)...
Error: MapiExceptionNoAccess: Unable to query table rows. (hr=0x80070005, ec=-2147024891)...
Error: MapiExceptionNoAccess: Unable to query table rows. (hr=0x80070005, ec=-2147024891)...
Error: MapiExceptionNoAccess: Unable to query table rows. (hr=0x80070005, ec=-2147024891)...
Only fix so far is to export data to pst, recreate mailbox, import data back... 

February 24th, 2015 9:32am

Exch 2k10 SP3 RU6 (i think)

Yep, we're at the same level.

I haven't found a way around this, nor do I have an explanation for why it ha

Free Windows Admin Tool Kit Click here and download it now
February 24th, 2015 9:34am

This is a consequence of implicit remoting.  When you use implicit remoting, the cmdlets (actually proxy functions) are sent back to the computer the were imported from for execution and the results returned to your local session. 

When you run that script, the Get-MoveRequest is sent back to the Exchange server, and it starts sending you back the MoveRequest objects.  Then you try to pipe that into another imported cmdlet/function (Get-MoveRequestStatistics), and it tries to send that back to the Exchange server to execute, but the Exchange server can't do that because it's still got MoveRequest objects queued up to send you, so it's basically blocked from sending you anything else until it's finished with that.

Thanks Rob.

Did u ever encounter a problem when u cannot move mailbox to another database?

No, I haven't ever had any problems with moves. I haven't had to do many though.

February 24th, 2015 9:38am

Exch 2k10 SP3 RU6 (i think)

Yep, we're at the same level.

I haven't found a way around this, nor do I have an explanation for why it ha

Free Windows Admin Tool Kit Click here and download it now
February 24th, 2015 9:44am

That's why it works if you just save all the MoveReqeusts to a variable first, and then foreach through that collection.  The Exchange server session got to unload it's output queue after doing the Get-MoveRequest, and is ready to receive new cmdlets to run (Get-MoveRequestSt
February 24th, 2015 9:57am

Thank you for an explanation.

Cheers

Free Windows Admin Tool Kit Click here and download it now
February 24th, 2015 10:13am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics