Are you waiting for the job to complete first? There’s really no advantage to using Start-Job if you’re just going to immediately try to fetch the results.
Just for giggles, try adding a unary comma when calling Start-Job:
This is because the -ArgumentList parameter accepts an array. If your $f variable contains multiple objects, and you don’t use the comma, then only the first element of the array will be bound to your $value parameter (and the rest would show up in the automatic $args array.) By using the unary comma, $value will be equal to $f (the entire contents of the array).
Or, in this case, you could just not bother with a param block and use the automatic $args variable:
Dave,
You had asked if I was waiting for the job to finish. Sorry I did not include that in the original question. I am using Start-job to use a progress bar so the tech using the script will not think that it has stopped on large directory/files. Here is the rest of the section you helped me with.
$ScriptBlock = {$args | Group-Object -Property Length | where {$_.Count -GT 1}}
Start-Job -ScriptBlock $ScriptBlock -Name GrpLength -ArgumentList $ddup
$i = 0
do {Write-Progress -Activity "Grouping files by length Please Wait " -Status "$i Time elapsed in Seconds"
sleep 1
$i++
$job2 = Get-Job -Name GrpLength
}
while ($job2.state -eq "Running")
$ddup1 = Receive-Job -Name GrpLength -Keep