By, you’ve most likely heard about the new -parallel parameter with ForEach-Object in the latest preview of PowerShell 7 Personally. I’ve been waiting for this for a long time. I used to only use PowerShell workflows because it offered a way to run commands in parallel. Having this feature as part of the language is…
Tag: ForEach
Why Doesn’t My Pipeline Work?
I saw a little discussion thread on Twitter this morning which I felt needed a little more room to explain. Plus since we’re in ScriptingGames season beginners might like a few pointers. I always talk about PowerShell, objects and the pipeline. But sometimes what looks like a pipelined expression in the PowerShell ISE doesn’t behave…
Pipeline Power
Last week I came across a blog post that had a decent example using PowerShell and PowerCLI to get the disk location for all virtual machines. The posted code works and does display the information you might be after. $myVMs = get-vm foreach($vm in $myVMs){ $myDisks = @($vm | get-harddisk) foreach ($disk in $myDisks) {…
ForEach or ForEach-Object
I came across a post the other day that explained differences when using the ForEach enumerator and the ForEach-Object cmdlet. They both essentially do the same thing but as the post mentions there are potential performance differences. One other difference I want to highlight is that the ForEach enumerator doesn’t write to the pipeline at…
Friday Fun Create Numbered File
I was working on my guest commentary for the upcoming Scripting Games and started thinking I would need a line numbered version of my solution to help explain. Turns out I didn’t go down that road, but in the process I put together a little PowerShell to take a text file and create a line…