[英]Selecting Processname by string containing with WASP in Powershell
我正在嘗試使用WASP在Powershell腳本中選擇某個進程名稱。 但是,問題在於,每次啟動進程時,它都會在擴展之前給自己一個隨機生成的字符串。
但是,它始終始終包含擴展名“ .tmp”。 無論如何,如果字符串末尾包含.tmp,我可以選擇該進程嗎? 在這種情況下,我嘗試選擇的進程是“ is-RI4E5.tmp”。 我需要基於它的末尾擴展名“ .tmp”來選擇它。
ProcessName ProcessId IsActive Handle Title Class
----------- --------- -------- ------ ----- -----
powershell_ise 8652 True 133330 Administrator: Windows PowerShell ISE HwndWrapper[PowerShell_ISE.exe;;cf...
is-RI4E5.tmp 6720 False 461306 Setup TApplication
explorer 5472 False 264168 VNC Server CabinetWClass
explorer 5472 False 985230 vnc - Search Results in SharedFiles (\\cas-fs1) (S:) CabinetWClass
chrome 7636 False 329808 Central Arizona Supply - Home - Google Chrome Chrome_WidgetWin_1
cmd 7592 False 264396 Administrator: C:\Windows\system32\cmd.exe ConsoleWindowClass
EXCEL 8860 False 1116322 Microsoft Excel - CAS Network IP Directory [Compatibility Mode] XLMAIN
EXCEL 8860 False 395668 Printers MS-SDIb
VNCScan 9104 False 198140 Bozteck VENM Console 2013.6.3.230 WindowsForms10.Window.8.app.0.378734a
EXCEL 8860 False 461030 CAS Network IP Directory [Compatibility Mode] MS-SDIb
我建議在開始WASP流程之前收集所有進程名稱。 一旦開始,再次收集所有過程,並使用Compare-Object比較兩個集合。 當多個進程帶有“ .tmp”后綴時,這將減少誤報的機會。
$beforeWasp = Get-Process | Where-Object { $_.Name -Like '*.tmp' }
# start process here
$afterWasp = Get-Process | Where-Object { $_.Name -Like '*.tmp' }
Compare-Object -ReferenceObject $beforeWasp -DifferenceObject $afterWasp -PassThru
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.