Hi Akhil,
You may find the attached sample PowerShell script useful for this. This was designed to run at regular intervals and check the Windows event log for certain conditions and then restart a resource after clearing temporary files. You could use this as a template for your own requirements and modify as required.
This was kindly donated by another customer who thought it may be useful for others.
------------------------------
John Cowell
Senior Software Support Analyst
Blue Prism
------------------------------
John Cowell
Senior Software Support Analyst
Blue Prism