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