8,330 questions
1..5 | % -Parallel { "this is thread $_" } -ThrottleLimit 5
this is thread 1
this is thread 2
this is thread 3
this is thread 4
this is thread 5
Some other answers here: https://stackoverflow.com/questions/68874167/is-there-a-way-to-get-the-tid-thread-id-in-powershell-foreach-object-parallel For example managed thread id's:
1..2 | % -Parallel { [System.Threading.Thread]::CurrentThread.ManagedThreadId }
110
100