Category filter
Script to get performance details of Windows devices
Devices can get slow and inefficient over time due to the clogging of unwanted cache and data. Certain apps often loot the system resources without the user’s knowledge. It’s good practice to monitor your device’s performance details regularly. With Hexnode’s Execute Custom Script action, you can execute custom scripts that will fetch various performance parameters of your Windows device.
PowerShell script
By running this script, you can get the details of various performance parameters like CPU usage, memory usage, disk usage, total physical memory, available physical memory, virtual memory available, and virtual memory in use.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# Open Task Manager Start-Process -FilePath taskmgr # Retrieve CPU usage $cpu = (Get-Counter -Counter "\Processor(_Total)\% Processor Time").CounterSamples.CookedValue # Retrieve memory usage $memory = (Get-Counter -Counter "\Memory\Available MBytes").CounterSamples.CookedValue # Retrieve disk usage $disk = (Get-Counter -Counter "\LogicalDisk(_Total)\% Free Space").CounterSamples.CookedValue # Output the results Write-Output "CPU usage: $cpu%" Write-Output "Memory usage: $memory MB" Write-Output "Disk usage: $disk%" systeminfo | findstr /C:"System Up Time" /C:"Total Physical Memory" /C:"Available Physical Memory" /C:" Available Virtual Memory: " /C:"Virtual Memory in use" |