You can specify the name of the task using the parameter -Name:
Start-Job { Write-Host "hello"} -Name "HelloWriter"
Get-Job:
Get-Job -Name HelloWriter
:
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
3 HelloWriter BackgroundJob Completed True localhost Write-Host "hello"
Start-Job :
$worldJob = Start-Job { Write-Host "world"}
, $woldJob :
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
7 Job7 BackgroundJob Completed True localhost Write-Host "world"
. Register-ObjectEvent, , :
$job = Start-Job { Sleep 3; } -Name "HelloJob"
$jobEvent = Register-ObjectEvent $job StateChanged -Action {
Write-Host ('Job #{0} ({1}) complete.' -f $sender.Id, $sender.Name)
$jobEvent | Unregister-Event
}