Hello Vedang Agarwal,
Thank you for posting in Q&A forum.
I am sorry, I'm not very familiar with scripting.
I think you could use PowerShell command, such as get-event/get-eventlog.
Here is the link for your reference:
Get-EventLog (Microsoft.PowerShell.Management) - PowerShell | Microsoft Learn
Get-Event (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn
I hope the information above is helpful.
If you have any questions or concerns, please feel free to let us know.
Best Regards,
Daisy Zhou
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.