I'm in a need to get a list of all the ASP.NET running worker process and its associated application pools and process ID.
Is there a way to do this pragmatically (C#) or a powershell script?
Identify Worker Process in IIS 6.0
cscript iisapp.vbs
From IIS 7.0 you need you to run IIS Command Tool ( appcmd ) .
appcmd list wp
If you want to save that list to text file, just append >> myfile.txt after command.
Now, here you can see iisapp.vbs source code.
It uses WMI to get all the information. Looks simple to rewrite this to C#.
Anyway, complete article where i found this info can be seen here: Identifying Worker Process (w3wp.exe)