How to have index variable increase in ForEach-Object?
I have this strange observation: I want to run an expression for as many times as there are files. Yet, the following script always executes only once, no matter how many files are found by Get-ChildItem: (Get-ChildItem -Filter ‘*.png’), (Get-ChildItem -Filter ‘*.jpg’) | Sort-Object -Property ‘Name’ | ForEach-Object -Begin { $idx = 0 } -Process… Read More How to have index variable increase in ForEach-Object?