$args
is an array, if you still want to use make sure to pick its first element:
$parentProcessID = $args[0]
Also, Get-Process
has an Id parameter, there's no need to use the Where-Object
cmdlet:
Get-Process -Id $parentProcessID
Another avantage of the Id parameter is that it takes an array of Id's so it would have work if you passes to it the value of $args
as is.
You can also use names parameters for the scriptblock instaed of using $args
:
Start-Job {
param([int[]]$procid)
$MyProcess = Get-Process -Id $procid
(...)