问题
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