Start-Job via Invoke-Command: Job is only available in remote session

Viewed 1204

I'm trying to start TShark on different servers via following command:

Invoke-Command -Session $remoteSession -ScriptBlock {start-job -ScriptBlock {& 'C:\Program Files\Wireshark\tshark.exe' -b filesize:10000 -b files:5 -w "$tsharkResultDirectory\tshark.pcap"} -Name "TShark"}

The command works and everything is fine. But when I connect to the remote server via e.g. remote desktop, and perform the command Get-Job nothing is returned. So that means that the beforehand started job only runs in the remote session. Does anybody know if there is a way to start a job in "global" scope. I don't want that TShark stops tracing if I accidentally close my PowerShell window.

Thx

1 Answers
Related