Checking Process Age Powershell Script

The other day I stumbled across a powershell that is useful for checking out the age of a process running on a computer, unfortunately I cannot remember where I discovered it and therefore cannot give the relevant credit to the creator.

I can here many of you say, about why is this Powershell script important and why have I placed it alongside the Veeam information?

The answer to these questions is simple, the powershell script is especially useful when using Veeam Backup & Replication and it was due to a situation I had when using Veeam Backup & Replication that allowed me to look for the script in the first place.

With Veeam Backup & Replication v6, the Management Server communicates with the Proxies and starts up the VeeamAgent.exe process when backing up or replicating.  Each task that is running, will create a process like this.  In some circumstances, a Backup job may freeze even though other jobs are running through smoothly.  I knew that if you kill the VeeamAgent.exe process, it would stop the backup job and allow you to restart it later… unfortunately I didn’t want to stop all VeeamAgent.exe processes on the proxy as that would kill the backup jobs that are working fine.  If I knew the age of the VeeamAgent.exe processes and compare the start time with the start time of the virtual machine backup that has frozen… I would then be able to kill just that process and allow the other backup tasks to continue running.

So here is the script:







$Processes = Get-WmiObject -Class Win32_Process -ComputerName $ComputerName -Filter “name=’$ProcessName'”

if($Processes) {

foreach ($process in $processes) {

$processid = $process.handle

$processcreationtime = $Process.Converttodatetime($Process.creationdate)

write-host “`nThe $ProcessName `($processid`) process creation time is $processcreationtime”


} else {

write-host “`nNo Process found with name $ProcessName”


write-host “”


This script should be saved in a .ps1 file and stored somewhere on your network.  To run the script, start up Powershell.  I find it easier to browse to the folder where the script is located and execute the following command:

./nameofscript.ps1 -ComputerName NameofComputer -ProcessName NameofProcess

So for in my environment, I actually have it available on the server that is the Veeam Proxy and therefore I start it as the following:

./get-processage.ps1 -ProcessName VeeamAgent.exe


At this poing you will see something similar to below:

At this point you compare the date and time of the processes with the start time of the frozen virtual machine backup, you can then start up a command prompt on the Proxy server and run the following command to kill the process:

taskkill /PID processnumber /F

The process number is the item in brackets and therefore in our example above, if we wanted to kill off the oldest process, we would run the following command:

taskkill /PID 948 /F

Seconds later the backup task will fail, at which point you can investigate the reason for it freezing and restart your backup task again.

About the Author


I have been in IT for the past 15 years and using virtualisation technologies for around the past 8 years. I started, as quite a lot of people do, working with PCs after playing with such iconic systems like the ZX81, ZX Spectrum and then progressing through 386s, 486s, Pentiums etc. After being headhunted at sixth form to work for a small company based around Hertfordshire, UK. I began working with small businesses and gaining a lot of hardware experience. Three years later, after helping to increase the size of the business, I needed to gain exposure to a larger environment to progress my own career. I joined a large manufacturing company around Electronic Test and Measurement which progressed my skills onto more PC work, hardware work and then onto Server Operating Systems. I progressed again onto a consultancy company based in Reading, UK. Initially working as an engineer performing hardware / software installations for larger companies contracted out to the consultancy company, I moved up into a Consultant position continuing my travel across the UK assisting and providing solutions to companies. I finally moved on again to my current position, working back in Hertfordshire, UK. Again working for a large manufacturing company, this time with over 50,000 users worldwide. I am responsible for the datacenter hardware, the storage environment, the vmware environment and also implementing their new Citrix XenApp farm. My days are busy but also productive, its a friendly environment and in my four years of being with the company, I have seen many changes in technology and infrastructure in use within the company. About the site I started this site as I had been thinking of having more of a presence on the web for a while. On a daily basis, I perform tasks and use tools that others may not use or may not think to do and therefore I thought that I would share some of these experiences and tips with others to help with their day to day work. Currently, my main focus of work is around VMware and Veeam Backup & Replication but hopefully as my tasks progress, I’ll be able to share useful bits of information about other areas of IT as well.

Leave a Reply

Your e-mail address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.