Category filter

Script to track app usage on Windows devices

Tracking app usage data, such as total time used and device storage occupied by each app, allows IT administrators to identify app usage patterns and make decisions to optimize the device’s performance. Removing unnecessary applications can free up storage space, improve device performance, and prevent employees from wasting work time on irrelevant apps. This document provides PowerShell scripts designed to track app usage on Windows devices. Using Hexnode’s Execute Custom Script remote action, administrators can execute these scripts on their Windows devices.

Disclaimer:


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

Track the usage of all Windows apps

This PowerShell script retrieves a list of all currently running processes and selects specific properties to display, including the process name, memory usage in megabytes, and the total running time. The script uses the Get-Process cmdlet to get the processes and Select-Object to choose and customize the output.

Custom properties are created after executing the script: one for memory usage, converting from bytes to megabytes and casting it to an integer, and another for the usage time, which calculates the elapsed time since the process started and formats it in days, hours, minutes, and seconds.

After the execution of the above script, we will get the usage data of all apps on the device. The output of the Execute Custom Script can be viewed from the Action History tab of the device.

The Action history tab displays the output after executing the script to track app usage of Windows apps

Track the usage of a specific Windows app

This PowerShell script checks for a running process with a specified application name. First, the script defines the application name to search for and retrieves the list of all running processes. It then filters the processes to find one that matches the specified application name. If the process is found, the script calculates the memory usage in megabytes and the total running time, displaying these details along with the application name. If the process is not running, it informs the user that the specified application is not found.

Replace the AppName with the desired app’s name. After the execution of the above script, we will get the usage data of the specified app. The output of the Execute Custom Script can be viewed from the Action History tab of the device.

The Action history tab displays the output after executing the script to track app usage of a specific Windows app

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.

  • Sample Script Repository