Adventures in PowerShell Alchemy: Turning Code into Solutions

pXLabs Poor Admins Software Metering Package

pXLabs Poor Admins Software Metering Package

šŸ’ø Because your budget said no to Log Analytics…
šŸ› ļø But you still need to know what software your users are running!

🧐 What Is This?

pXLabs.PoorAdminsSoftwareMeteringPackageĀ is a homemade PowerShell-based software metering solution built for Intune-managed environments that lost traditional metering when moving away from ConfigMgr. It’s lightweight, runs silently in the background, and logs application usage to a simple CSV.

Then, because we’re resourceful, we sync the results toĀ OneDrive,Ā SharePoint, or any other location your budget will tolerate.

This is for all the admins out there that areĀ ā€œmissing our software metering data because we moved to Intuneā€. You’re not alone.


šŸ” What It Does

  • šŸ•µļø Tracks process start and stop events (Event IDs 4688 & 4689)
  • ā± Correlates runtime durations
  • 🫼 Filters system and noise processes
  • šŸ“‹ Outputs usage logs to simple CSV files
  • ā˜ļø Supports syncing results to OneDrive or other paths
  • šŸ›” Works without Log Analytics, Endpoint Analytics, or any paid plans
  • 🧰 Comes with a basic GUI to manage filter rules

šŸ“¦ What’s Included

  • Install.ps1: Installs the background scheduled task. Also supports uninstall viaĀ -UninstallĀ switch.
  • Detect.ps1: Used with Intune detection logic
  • SoftwareMetering.ps1: The main metering script
  • ProductFilterEditor.ps1: A GUI editor for managing product/version filters
  • ProductFilters.json: Customize which apps to include
  • SyncUsageData.ps1: Onedrive sync routine

šŸš€ How It Works

  1. Scheduled TaskĀ runs the metering script hourly (hidden + silent).
  2. Script reads filters fromĀ ProductFilters.jsonĀ (which you can manage with a built-in GUI).
  3. It queries Event Logs for new process starts and stops, pairs them up, calculates runtime, and writes to CSV.
  4. CSV is saved to a local path (e.g.,Ā C:\ProgramData\pXLabs\SoftwareMetering\Logs\).
  5. From there? Sync to OneDrive, SharePoint, or grab it with a script. You do you.

šŸ–¼ GUI for Filter Management

Run:

.\ProductFilterEditor.ps1

This lets you add, remove, or edit software filters. Don’t worry, if you forget to typeĀ .exe, we’ll add it for you.


šŸ›  Requirements

  • Windows 10 or 11
  • PowerShell 5.1+
  • Admin rights to install the task
  • Event Log auditing enabled for process creation and termination

Enabling Event Log Auditing

  1. OpenĀ Local Security PolicyĀ (secpol.msc) or use a GPO
  2. Navigate toĀ Advanced Audit Policy Configuration > System Audit Policies > Detailed Tracking
  3. Enable:
    • Audit Process Creation
    • Audit Process Termination
  4. RunĀ gpupdate /forceĀ or reboot to apply

🚔 Create Intune Win32 App

  1. Package the scripts:
IntuneWinAppUtil.exe -c <source_folder> -s Install.ps1 -o <output_folder>
  1. In Microsoft Intune:
    • Go toĀ Apps > Windows > Add
    • SelectĀ App type: Windows app (Win32)
    • Upload theĀ .intunewinĀ file
    • Configure theĀ install command:powershell.exe -ExecutionPolicy Bypass -File .\Install.ps1
    • Set theĀ detection ruleĀ to useĀ Detect.ps1
    • (Optional) To support uninstall, configure:powershell.exe -ExecutionPolicy Bypass -File .\Install.ps1 -Uninstall
    • Assign to your devices or user group

šŸ“… Output Format

CSV columns include:

  • Timestamp
  • ComputerName
  • UserName
  • Product
  • Version
  • Runtime (in minutes.seconds)

šŸ¤” Why This Exists

Because you:

  • Moved to Intune and lost metering
  • Don’t have Microsoft E5 licenses
  • Can’t enable Log Analytics or Kusto Queries
  • Still need to know who’s running what (and for how long)

This tool fills that gap.


šŸ”„ Syncing Usage Logs to OneDrive

To help automate backing up your software metering logs, the install script sets up a scheduled task that runs theĀ SyncUsageData.ps1Ā script every 4 hours.

What it does:

  • Moves the current CSV log file (UsageData.csv) from the local logs folder (C:\ProgramData\pXLabs\SoftwareMetering\Logs) into your OneDrive folder underĀ SoftwareMetering\
  • Renames the file on move to include the computer name and timestamp, e.g.,Ā COMPUTERNAME-UsageData-2025-05-23_14-30.csv
  • Automatically creates the OneDrive folder if it doesn’t exist
  • Cleans up old files in OneDrive older than 30 days for space management
  • If OneDrive is not detected (environment variable missing), the script exits silently without error

How it works:

  • The script expects that OneDrive is installed and signed in for the user running the scheduled task
  • Files are moved, not copied, so the localĀ UsageData.csvĀ resets for fresh logging
  • Old historical CSV files in OneDrive are pruned automatically

Customization:

TheĀ SyncUsageData.ps1Ā script is provided as a working example to upload logs to OneDrive. You can modify it to sync or upload the CSV files toĀ any other path, network share, FTP server, cloud storage, or web API endpointĀ as your environment and requirements dictate. Just replace the file copy/move logic with your preferred method.

šŸ“” Optional Enhancements

  • Parse results into Power BI
  • Extend for specific departmental apps
  • Auto-upload to Azure Blob or FTP

šŸ“„ License

This project is licensed under theĀ GNU General Public License v3.0. Feel free to modify, share, and contribute!


šŸ™ Credits

Built by Jeff Pollock at pXLabs
🌐 https://pxlabs.info
šŸ™Ā GitHub – @phriendx
Inspired by real-world IT budgets and for all the admins doing more with less.

Share this

Jeff Pollock Avatar

Leave a Reply

Your email address will not be published. Required fields are marked *