Wednesday, October 26, 2011

Quit Blocking My Pipeline!

A really cool feature of PowerShell is the async nature of the pipeline, whereby the first command outputs to the next command as soon as it has any results (so BEFORE it is done collecting ALL of its results).

Sometimes because of filtering or selection you only want a subset of the results from the previous command.  In these cases it is nice to not have to wait for that first command to finish, but if that command blocks the pipeline you get to wait for it to complete.

This is one of the annoyances of Export-FimConfig.  Though it is a very useful cmdlet it does block the pipeline.  You can see from my script below that I am only looking for the first item from the output.  I can only get that first item AFTER all the results are returned.

If this is an annoyance for you too then feel free to vote for the feedback on Connect.

A reasonable workaround is to instead write your own cmdlet to replace Export-FimConfig (such as the FIM cmdlets on CodePlex thanks to Quest), but it sure would be nice for this to just work.

No comments: