SQL Server Profiler 向我显示特定数据库访问器的进程 ID。
Windows 任务管理器向我显示该进程 ID 属于 W3wp.exe。
我如何将其绑定回网络应用程序? (我有多个 Web 应用程序在此服务器上运行。)
旧帖子,但我还没有看到我通常使用的解决方案。
它将返回一个列表:
w3wp#(instance number) = ProcID, APPPool Name
请注意,我不是一名编码员,可能有更有效的方法。然而,这在 PowerShell 中对我来说很有效:
$count = (Get-Process | Where-Object {$_.Name -eq 'w3wp'}).count -1
$var = 1
$result=''
while ($var -le $count) {
$id = (Get-Counter "\Process(w3wp#$var)\ID Process").CounterSamples.CookedValue
$app = [regex]::match((Get-CimInstance Win32_Process -Filter "ProcessId = $id").CommandLine, '"([^"]+)"').Groups[1].Value
write-host "w3wp#$var = $id, $app"
$result += "w3wp#$var = $id, $app`n"
$var += 1
}
$result
powershell解决方案
import-module webadministration
Get-ChildItem IIS:\AppPools\DefaultAppPool\WorkerProcesses
产生此输出:
进程状态处理开始时间 身份证
17480 运行 638 8/9/2023 11:29:17 AM