How to create environment variables in PowerShell:
http://scriptolog.blogspot.com/2007/08/creating-environment-variables...
You can also set each job (script) to write a text file containing your own
custom data (delete at the end of the job)
which the other jobs can check.
As for distinguishing your job from all other PowerShell instances:
# get your running powershell process id
$cid = [System.Diagnostics.Process]::GetCurrentProcess().id
# get all posh instances excluding yours
gps powershell | where {$_.id -ne $cid}
---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
RA> "RickB" <rbiel
...@i1.net> wrote in message
RA>
news:0937b5b9-4537-424f-bb99-621563fa835c@34g2000hsh.googlegroups.co RA> m ...
RA>
>> I differentiated instances of PowerShell
>> by having code like this in each monitor.
>> $host.UI.RawUI.WindowTitle = 'Descriptive_Text'
>> Then I could do this to tell which monitors were running
>> get-process 'powershell'|% {"'$($_.MainWindowTitle)' is running"}
>> If I wanted to find and kill a particular instance
>> get-process 'powershell'|?{$_.MainWindowTitle -eq
>> 'Descriptive_Text'}||%{$_.kill()}
RA> ...
RA>
>> Is there a more reliable method?
RA> I don't know but I have been looking for a related solution
RA> for IE tasks. E.g. I would like to know which are which too
RA> and IE tasks' titles change so I couldn't use your method
RA> even if it was reliable.
RA> Coincidentally, just yesterday I discovered
RA> the wealth of information this can give me:
RA> get-process iexplore | format-list *
RA>
RA> Apparently I need to expand also the StartInfo member separately.
RA>
RA> (get-process iexplore).StartInfo
RA>
RA> does get something but not very much is filled in. YMMV?
RA>
RA> So, perhaps I could differentiate between tasks using
RA> EnvironmentVariables? E.g. this expands them all
RA>
RA> (get-process iexplore).StartInfo.EnvironmentVariables
RA>
RA> Can I add one to a running task which shows there too?
RA>
RA> I don't know how to do that in PS but I just checked with
RA>
RA> (get-process cmd).StartInfo.EnvironmentVariables
RA>
RA> for "proof of concept" and it didn't list anything new that I
RA> created using the set command. Rats. ; }
RA>
RA> Perhaps PS makes its Environment variables more accessible than
RA> cmd.exe does? Or maybe StartInfo is just the wrong place to be
RA> looking for dynamically created ones? ; )
RA>
RA> An alternative which would be almost as good for me
RA> and which might help you would be to be able to show
RA> the command line that started the task. Process Explorer
RA> can show me that... Or not? (Also somehow not reliable.)
RA> Wow. (Serendipity.) ProcExp has a Comments: line
RA> in the Image tab (where I was expecting to see the Command
RA> line.) Then it shows up as the second line of the tooltip for
RA> the process' name. That will be useful! Thanks for making
RA> me find this. ; )
RA> Good luck
RA>
RA> Robert Aldwinckle
RA> ---
>> If it matters, the server is 2003 and PowerShell is CTP2. The jobs
>> are started using the builtin scheduler.