EDIT by OP: My question presupposed that PowerShell was the best tool for this job. There is a simpler way of achieving my goal. A friend just told me about: iisapp.vbs. It displays exactly the info I need without requiring PowerShell.
I'm working with dozens of ASP.NET websites running locally and when I want to debug a particular website named, for example, foo.site.com I go through the following steps:
Run Process Explorer (from SysInternals) and find which w3wp.exe was started with foo.site.com on its command line.
Note the Process ID (PID) of that w3wp.exe process.
In Visual Studio attach to that process ID.
Is there a way to write a PowerShell script that will print the PID and Command Line Arguments of every w3wp.exe process running on my computer?
When I run get-process w3wp I get:
> get-process w3wp
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
688 28 44060 64576 226 2.75 196 w3wp
750 26 48328 68936 225 3.38 1640 w3wp
989 36 54596 83844 246 4.92 1660 w3wp
921 33 54344 80576 270 4.24 5624 w3wp
773 27 48808 72448 244 2.75 5992 w3wp
No Command Line information :(
Thanks!
EDIT: I am looking for the command line arguments that were passed to w3wp.