PowerShell中显示进程所属用户
首先,以管理员身份打开PowerShell。
输入:
get-process -includeusername | format-table -autosize
显示如下:
Handles WS(K) VM(M) CPU(s) Id UserName ProcessName ------- ----- ----- ------ -- -------- ----------- 445 18968 290 1,836.91 2944 HOMEPC\Raymond Agent 92 2384 26 0.02 2336 NT AUTHORITY\LOCAL SERVICE alg 253 7304 85 0.39 6480 HOMEPC\Raymond alicnotify 380 7916 82 549.81 1656 NT AUTHORITY\SYSTEM AlipaySecSvc 183 4228 102 19.34 3308 NT AUTHORITY\SYSTEM atieclxx 128 2288 26 0.05 896 NT AUTHORITY\SYSTEM atiesrxx 176 11296 70 0.19 6488 audiodg 720 6920 295 255.91 5268 HOMEPC\Raymond baiduyun 845 65676 383 8,915.66 2316 HOMEPC\Raymond BaiduYunGuanjia 929 155600 572 3,104.13 5628 HOMEPC\Raymond Battle.net 1322 15560 168 2.53 7592 HOMEPC\Raymond BingIMEPlatform 75 2308 24 0.11 1740 NT AUTHORITY\SYSTEM BingIMEUpdateService 95 2892 82 0.69 3952 HOMEPC\Raymond CBGrabConnect_x64 141 2660 97 0.27 5368 HOMEPC\Raymond CCBCertificate 172 2592 83 0.05 6320 HOMEPC\Raymond certd_nps3000_ICBC
如果不想用管理员身份的话,可以用(命令中的引号内容的空格不能省略):
tasklist /V /FO CSV | ConvertFrom-Csv | Select-Object -Property "映像名称","会话# ","会话名 ","用户名 " | Format-Table -AutoSize
结果如下:
映像名称 会话# 会话名 用户名 -------- -------- ------------ --------- System Idle Process 0 Services NT AUTHORITY\SYSTEM System 0 Services 暂缺 smss.exe 0 Services NT AUTHORITY\SYSTEM csrss.exe 0 Services NT AUTHORITY\SYSTEM wininit.exe 0 Services NT AUTHORITY\SYSTEM csrss.exe 1 Console NT AUTHORITY\SYSTEM winlogon.exe 1 Console NT AUTHORITY\SYSTEM services.exe 0 Services NT AUTHORITY\SYSTEM lsass.exe 0 Services NT AUTHORITY\SYSTEM svchost.exe 0 Services NT AUTHORITY\SYSTEM