Member-only story
5 Awesome Tips And Tricks You Can Use With PowerShell V7
Remember when PowerShell shook things up with version 7? Well, they’ve kept the momentum going with their releases, now already at 7.4.1 at the time of writing. Therefore, its new features and capabilities could’ve slipped under your radar.
Time to roll up those sleeves and get right into it! I’ve got some awesome PowerShell tips and tricks from version 7 that could really simplify things for you!
The Foreach-Object Parallel Parameter
The Foreach-Object -Parallel
cmdlet was introduced at the start of PowerShell version 7 to increase the processing in parallel for each piped input object. In combination with the -ThrottleLimit
, you could significantly increase the speed of your scripts.
Take the following example below.
As you can see, it took roughly 14 seconds to execute. Compare that when you add the -Parallel
parameter.
That’s way faster! This feature in version 7 also supports the ability to run it -AsJob
, making it even more interesting.
When you want to run things in parallel, always consider when you should use it:
- If your scripts have a lot of data over a period of time, it is worthwhile to run them in parallel