A colleague shared a blog post regarding the use of the Foreach loops with the parallel parameter in PowerShell ( http://sqlblog.com/blogs/jamie_thomson/archive/2014/12/09/parallel-foreach-loops-one-reason-to-use-powershell-workflow-instead-of-ssis.aspx ). I wanted to do a quick test to see some of the overhead so I wrote a quick snippet with Start-Sleep within a foreach loop. The PowerShell below is for example purposes only. There is most likely an intercept or titration point in which the use of -parallel would not be needed. In other words, if only processing 5 or so objects that are completed very quickly. I see were the use of the -parallel parameter could be extremely useful when attempting to process a large collection of objects (e.g. SharePoint Site Collections) and the methods you are using do not impact each other.
FYI ForEach is an Alias for ForEach-Object
———– —- ——- ——
Alias foreach -> ForEach-Object
I will need to test during some SharePoint Management and reporting things I have in the hopper.
This post first appeared on MSDN Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The MSDN Blogs., please read the originial post: here