I have a (inherited) PowerShell script that calls other PowerShell scripts, invoking them using the Start-Joband cmdlet -FilePath. For example, I have a script that does nothing:
Start-Sleep -Seconds 86400
What can I call through the task:
PS> Start-Job -Name "Test Job" -FilePath ".\Wait-AllDay.ps1"
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
2 Test Job BackgroundJob Running True localhost Start-Sleep...
PS> Get-Job -Id 2
State : Running
HasMoreData : True
StatusMessage :
Location : localhost
Command : Start-Sleep -Seconds (60*60*24)
JobStateInfo : Running
Finished : System.Threading.ManualResetEvent
InstanceId : 0c0e2c32-cbc5-4d70-b7cb-28771626cf20
Id : 2
Name : Test Job
ChildJobs : {Job3}
PSBeginTime : 25/01/2016 15:06:22
PSEndTime :
PSJobTypeName : BackgroundJob
Is there a simple and reliable way to find out which process is associated with this work (which, in my opinion, will be additional powershell.exe )? Obviously, this is easy when testing with only one task, but on the server I can have many such starts at the same time.
Why do I want to do this / know?
, , . , Start-Job, , ( ) , . , , , , , .
, , , , .