Two ways to get your running PowerShell process:
PS > gps -id $pid
or
PS > [System.Diagnostics.Process]::GetCurrentProcess()
---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
F> Hi,
F>
F> I have a Windows 2008 Task which executes every 15 minutes. I need
F> for this
F> process to be running continuously. Ideally, when the process
F> starts, it
F> should check to see if an instance is running. The task is a
F> powershell
F> script. If it is running, then stop, if not, then continue to
F> execute. What
F> is the best way to accomplish this? Also, how would I get my own
F> process id?
F> If I could get my own pid, then I guess, putting this in a file and
F> then gps
F> powershell|?{$_.id -eq 5812}, would work.
F> Thanks in advance,
F>


