Find Latest Processes

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Award-winning PowerShellPlus


Admin Guide to PowerShell Remoting


Mastering PowerShell eBook

You should try this piece of code to find all processes that were started within the past 10 minutes:

Get-Process | Where-Object { try { (New-Timespan $_.StartTime).TotalMinutes -le 10} catch { $false } }

This  will only cover processes that you started yourself—unless you have Administrator privileges.

 

Twitter This Tip! ReTweet this Tip!


Posted Apr 12 2011, 08:00 AM by ps1

Comments

Ben wrote re: Find Latest Processes
on 04-12-2011 9:24 AM

Love the script. Only tweak I'd make would be to filter out the $null $_.StartTimes with the where clause instead of using the try/catch to do it.

ps | ?{ $_.StartTime -and (New-Timespan $_.StartTime).TotalMinutes -le 10 }

Hans O. Martinsen wrote re: Find Latest Processes
on 04-12-2011 9:56 AM

I kind of like this one better. :-)

Get-Process | ? { $_.StartTime -gt (Get-Date).AddMinutes(-10) }

Ben wrote re: Find Latest Processes
on 04-15-2011 1:33 PM

Hans wins ... hans down ;)

Copyright 2012 PowerShell.com. All rights reserved.