Reputation: 403
Say you have a single PowerShell script that can be started in multiple, simultaneous instances. Is there any way for those scripts to identify which process each of them is running?
Basically, I'm looking for something like an imaginary:
$MyInvocation.processID
Thanks.
Upvotes: 0
Views: 28
Reputation: 174990
Use the $PID
automatic variable:
$ThisProcess = Get-Process -Id $PID
Upvotes: 1