Identifying a specific worker process ID in IIS6 or IIS7

A lot of the time when I'm doing remote debugging I'll just attach to every worker process on the server, however, there are occasions when I want to attach to a worker process serving a particular application.  Fortunately in IIS6 it's fairly easy to identify the process id of each worker process.  Go to Windows -> System32 and you should find a vbs file named iisapp.vbs.  Running this will give you something similar to this.

Here, for example, if we wanted to debug the WebServices application pool then the process id is 184, simply take this id and select the w3wp.exe process with the corresponding id in the "Attach to process" window in Visual Studio.

Some of you, however, might have moved with the times and are running IIS7.  If this is the case then it's just as easy.  Go to Windows -> System32 -> Inetsrv and then run

appcmd list wp

This gives a very similar output to that of iisapp.vbs.