DaveWentzel.com            All Things Data

Background Task Processing

available in PS 2.0
 
Remoting must be enabled
 
$someJob = start-job -ScriptBlock {some code}
get-job
get-job -state completed
receive-job -job $someJob
 
once you do receive-job the job data is removed from the cache unless you receive-job -keep. 
 
Passing in parameters is a little bit tricky and non-intuitive:
 
start-job -ScriptBlock {something.ps1 $args[0] $args[1] $args[2]} -ArgumentList @($MyVar, $AnotherVar, $AThirdVar);
 
 
 
 

Add new comment