Splatting To #PowerShell Job

Splatting To #PowerShell Job

Category : Uncategorized

A while back I found a smart way to pass parameter to scripts in PowerShell background jobs.

Initially I was driven by the ambition to use Splatting and my first attempt looked like this:

It works, but in my view that approach reduces Splatting to absurdity. Therefore I continued trying different approaches and finally ended up with this surprisingly easy result:

If you like to use this approach please take into account:
– You need to pipe a PSCustomObject to Start-Job (rather than a hash table)
– For each parameter the Job script needs ValueFromPipelineByPropertyName set to $true such as below:

Hope this helps