tag:blogger.com,1999:blog-5384857.post1673947168925632546..comments2023-10-10T03:52:55.494+01:00Comments on Under The Stairs: Fun with the PowerShell PipelineUnknownnoreply@blogger.comBlogger2125tag:blogger.com,1999:blog-5384857.post-2031749544888271232015-01-18T11:40:11.108+00:002015-01-18T11:40:11.108+00:00Just because Start-service in pipeline doesn't...Just because Start-service in pipeline doesn't run. Check by yourself:<br /><br />Function Measureit {$m1 = (Measure-Command -Expression { <br /> Stop-Service -Name Spooler | <br /> Start-Service -Name Spooler<br /> <br /> write-host (Get-Service -Name "Spooler").Status -ForegroundColor Red<br /> }).milliseconds<br /><br /> $m2 = (Measure-Command -Expression { <br /> Stop-Service -Name Spooler<br /> Start-Service -Name Spooler<br /> <br /> write-host (Get-Service -Name "Spooler").Status -ForegroundColor Yellow<br /> }).Milliseconds<br /><br /> "{0,-10}{1}" -f $m1, $m2<br />}<br /><br />1..20 | %{measureit}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5384857.post-31090347637941344702015-01-16T23:46:50.494+00:002015-01-16T23:46:50.494+00:00While I am only starting to learn Powershell I bel...While I am only starting to learn Powershell I believe I have an answer to why using Pipelinging for these tasks is more efficient than running the tasks as a script of 3 lines. I just finished reading the Powershell.com eBook and pipelines can be processed either sequentially or simultaneously. From what your test results it would appear that the three tasks that are being sent through the pipe are occurring simultaneously which results in a much more faster completion time. While the same tasks run sequentially in a script are run, well just that, one after the other.<br /><br />http://powershell.com/cs/blogs/ebookv2/archive/2012/03/05/chapter-5-the-powershell-pipeline.aspx#streaming-real-time-processing-or-blocking-modeArcuss88https://www.blogger.com/profile/06395739992896392602noreply@blogger.com