P
P
Pavel2019-11-22 12:49:55
PowerShell
Pavel, 2019-11-22 12:49:55

Why does a variable disappear after one use in PowerShell in the Start-ThreadJob cmdlet?

I am writing
Start-ThreadJob -ThrottleLimit 500 -InputObject $for_list_pc -ScriptBlock { }
Inside scriptblok, according to the documentation, I use $input to access the variable passed through -InputObject $for_list_pc. But on the second call to $input, there is nothing there. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2019-11-22
@Svarog7

$input is a system variable and is automatically cleared when the block of work ends.
You can read more about it in the help with the Get-Help command about_Automatic_Variables

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question