Kill all Internet Explorer processes that have been running for more than 5 minutes using Powershell

拈花ヽ惹草 提交于 2019-12-10 21:07:03

问题


I would like to kill all Internet Explorer processes that have been running more than 5 minutes. This has to be a command in one line using Powershell v1.0.


回答1:


Another way:

 get-process iexplore | ? { ([DateTime]::Now - $_.StartTime).TotalSeconds -gt 300 } | stop-process



回答2:


Get-Process iexplore -ErrorAction SilentlyContinue |
Where-Object { $_.StartTime -and (Get-Date).AddMinutes(-5) -gt $_.StartTime } |
Stop-Process



回答3:


At least at powershell v2 following command should stop all IE processes older then 5 minutes:

Get-Process | 
    select -Property ProcessName, StartTime |
    ? { (($_.StartTime -ne $null) -and
         (([DateTime]::Now - $_.StartTime).TotalMinutes -ge 5) -and
         ($_.ProcessName -eq "iexplore")) } |
    Stop-Process



回答4:


If you want to remove the first process only, with high CPU usage :

get-process iexplore | sort –descending cpu | select –First 1 | stop-process


来源:https://stackoverflow.com/questions/11410293/kill-all-internet-explorer-processes-that-have-been-running-for-more-than-5-minu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!