# 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](https://www.hexnode.com/mobile-device-management/help/executing-custom-scripts-for-windows/) action, you can execute custom scripts that will fetch various performance parameters of your Windows device.

 Disclaimer:The sample scripts provided below are adapted from third-party open-source sites.

 

 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.

Get performance details of Windows devices

\# 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" 

   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" 

   

 

  

 Notes:- It is recommended to manually validate the script execution on a system before executing the action in bulk.
- Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.