Scripting and self-healing with VirtualMetric

As you guys might know I’m a big fan of scripting with API’s. In this blog I used the API of VirtualMetric monitoring software and created a self healing PowerShell script.

What is VirtualMetric?

VirtualMetric is realtime agentless monitoring software which is completely based on an API. All the data you see in the VirtualMetric dashboard comes from their API. And you can easily create your own dashboard by dragging and dropping. In the Inventory you can easily see your complete infrastructure and it gives you all the information about your servers, applications, eventlogs etc.

Whats really great about the tool is the ability to directly see how the API get the displayed data. You do this by clicking on the export button and selecting Export to JSON.

This will automatically bring you to the API to view the JSON data. This API uri can then be pasted to for example a PowerShell script to use this data.

Learn more about VirtualMetric on https://www.virtualmetric.com

The script

I wanted to make an example script with the API from VirtualMetric and show two self healing functions. This script authenticates to the API and then checks the status of Windows defender realtime scanning. When it’s disabled it will turn it back on. And it will check disk space, when it’s running low it will delete all files on C:\Temp. By running this script once every few hours I know my system has defender turned on and the C:\Temp folders aren’t full with files I don’t need. The defender function is really handy because sometimes during a upgrade or installation of new software I turn of realtime protection for performance reasons. And sometimes I do forget to turn it back on. Well now I don’t have to think about that anymore.

I hope this was informative. For questions or comments, you can always leave a reaction in the comment section or contact me: