Saas licensing costs are directly proportional to growth, and as environments branch out to different tools, tracking gets difficult. Administrators can utilize RMM platforms for a clear overview of usage data, monitor adoption trends, and spot unused licenses. This guide will discuss how to use scripting and automation for proactive, efficient, and auditable SaaS license tracking practices.
Custom RMM scripts to automate SaaS license tracking
Effective software license management strategies allow organizations to forgo underutilized SaaS licenses and reallocate them, optimizing cost and budget control. From a managerial perspective, streamlined license viewing helps identify which works by analyzing trends and justifying license renewal or removal. Automating SaaS license management using RMM tools provides consistent enforcement and visibility—saving time, reducing manual labor, and minimizing costs.
📌 Prerequisites:
- RMM platform with scripting, reporting, and automation capabilities
- API credentials for SaaS platforms
- Admin privileges
- PowerShell, Bash, and CMD endpoint support
📌 Recommended deployment strategies:
| Choose a Method | 💻 Best for Individual Users | 💻💻💻 Best for Enterprises |
| Method 1: PowerShell scripts to query Microsoft 365 for license usage reports | ✓ | |
| Method 2: Monitoring and correlating RMM agent data for SaaS signals | ✓ | |
| Method 3: Generating longitudinal reports on SaaS usage | ✓ |
💡 Note: This guide outlines PowerShell, batch, and bash scripts you can deploy on RMM platforms that support these languages. For simplicity and consistency, we’ll use NinjaOne RMM as our primary platform in this guide.
💡 Adding custom scripts to the NinjaOne RMM console:
NinjaOne supports PowerShell, batch, and bash scripts, making it suitable for executing the scripts outlined in this guide. Here’s how you can add custom automation scripts inside NinjaOne’s script library:
- Launch the NinjaOne RMM console, then go to:
Administration > Library > Automation.
- Inside Automation, press Add and select New Script.
- Complete the necessary fields and parameters for your custom script.
- Enter the script of your choice to save it as an automation script.
- Ensure that the selected language matches the script’s language.
- Once saved, you can use NinjaOne’s built-in tools to select the target devices for automation by selecting the checkbox beside them.
Automate routine tasks and manage scripts centrally.
Method 1: PowerShell scripts to query Microsoft 365 for license usage reports
📌 Use Case: Administrators can use PowerShell scripts to automate SaaS license audits using an RMM platform.
📌 Prerequisite: PowerShell version 5.1 or later.
A. Connecting to Microsoft 365 to retrieve license agreements:
The following PowerShell script connects administrators to the Microsoft Graph API with the permission to read user and license data. This script retrieves all users with at least one assigned license, making it ideal for creating a license distribution inventory.
Connect-MgGraph -Scopes "User.Read.All","Directory.Read.All"Get-MgUser -All | Where-Object {$_.AssignedLicenses.Count -gt 0} | Select DisplayName, UserPrincipalName, AssignedLicenses
B. Export license usage data:
This script exports all user data into a CSV file, making it ideal for documenting and recording license usage. Through an RMM, administrators can schedule the script’s execution to generate license reports regularly.
Connect-MgGraph -Scopes "User.Read.All","Directory.Read.All"New-Item -ItemType Directory -Path "C:\Reports" -Force | Out-NullGet-MgUser | Export-Csv -Path "C:\Reports\LicenseUsage.csv" -NoTypeInformation
💡 TIP: You can replace C:\Reports with any path you want to designate as an export path.
Method 2: Monitoring and correlating RMM agent data for SaaS signals
📌 Use Cases: Administrators can leverage the services offered by their RMM platforms to infer SaaS app activity across managed endpoints.
Detect SaaS app processes for effective license tracking:
Administrators can utilize software inventory reports through an RMM platform, eliminating the need for scripting and manual inventory tracking. For example, NinjaOne shows software usage patterns, updates, and licenses, helping an environment manage and allocate software efficiently at scale.
Effective software inventory tracking can help trace when apps are installed or removed, providing insights on unused licenses for reallocation.
Scheduled reporting on software inventory
RMMs like NinjaOne can collect comprehensive data about software installations and uninstallations across multiple devices. They also help identify unauthorized and unlicensed software, making them ideal for seamless license compliance.
Administrators can package these insights into scheduled reports, providing clearer software inventory for proactive IT asset management and planning.
Method 3: Generating longitudinal reports on SaaS usage
📌 Use Cases: Leverage PowerShell scripts through RMM platforms to generate insights on SaaS license usage across environments over an extended period. Administrators can then compare generated reports to spot license usage trends over time.
📌 Prerequisite:
- Microsoft 365 or Azure AD-joined devices
- Administrator role
- Installed the Microsoft Graph PowerShell module
💡 Note: The example below tracks Microsoft 365 users within an organization and saves it as a weekly report. However, you can modify the script below to match your preferred parameters.
A. Script to create usage data snapshots periodically:
The following script retrieves all user accounts from Microsoft 365, including their usernames, emails, account status, and assigned licenses. The script then exports it to C:\SaaSReports as a CSV file and is labeled to match its creation date.
$date = Get-Date -Format "yyyy-MM-dd"$path = "C:\SaaSReports"if (!(Test-Path $path)) { mkdir $path | Out-Null }Get-MgUser | Export-Csv "$path\LicenseUsage-$date.csv" -NoTypeInformation
B. Sample script to compare previous reports:
After gathering enough license usage data, administrators can use scripts to compare different reports to chart license usage over time. Additionally, this can help identify inactive accounts for license reclamation, justifying the increase or decrease of licenses for an environment.
Compare-Object `-ReferenceObject (Import-Csv "C:\SaaSReports\LicenseUsage-2025-08-01.csv") `-DifferenceObject (Import-Csv "C:\SaaSReports\LicenseUsage-2025-08-08.csv") `-Property UserPrincipalName
⚠️ Things to look out for
| Risks | Potential Consequences | Reversals |
| Deploying scripts without ample testing | Not all environments are configured the same; scripts may behave differently across various organizations. | Test scripts locally within a controlled environment to verify their effectiveness before deployment. |
| Inaccurate script syntax and errors | Inaccurate script syntax and typographical errors can lead to errors, causing scripts to fail. | Double-check scripts for syntax accuracy, especially variables, paths, and cmdlets. Ensure that the required PowerShell modules and your target folders exist before writing files. |
| Platform mismatch | Cmdlets like Get-MgUser and Microsoft Graph modules won’t work on macOS and Linux devices. | Verify that your script’s logic is compatible with the operating system and command line interface you’re using. |
Troubleshooting issues related to SaaS license usage reports
Issue #1: Missing license data
Running a script to query the license usage report may sometimes return incomplete license assignments and user lists. Some common causes of this issue are expired API tokens or missing permission scopes. A workaround for this is to reinitialize the connection to Microsoft Graph by executing the following PowerShell script:
Connect-MgGraph -Scopes "User.Read.All","Directory.Read.All"
In addition to having the correct token and scopes, having sufficient admin rights to access license data is important. To verify, open the Microsoft 365 admin center, open the user account running the script, then go to assigned roles. This should show at least Reports Reader or User Administrator.
Issue #2: Scripts not executing via RMM
Check if your target PowerShell blocks the script through the execution policy feature by entering the following:
powershell.exe -ExecutionPolicy Bypass -File "C:\Path\To\YourScript.ps1"
💡 NOTE: Replace C:\Path\To\YourScript.ps1 with your script’s actual path.
Additionally, verify if you’re running scripts as USER or SYSTEM by executing the following:
Write-Output "Running as: $env:USERNAME"
For SaaS license monitoring, USER execution allows access to user-specific data and other variables tied to a logged-in user.
Issue #3: Incomplete endpoint logs
Configure the GPO to ensure audit policies are enabled on target endpoints. To do this, open gpmc.msc and then go to Computer Configuration > Windows Settings > Security Settings > Advanced Audit Policy. Ensure that Audit Logon, Audit Logoff, Audit Special Logon, and Audit Other Logon/Logoff are all enabled within a GPO linked to your target OU.
Considerations when using RMM for SaaS license tracking
Aside from creating license usage reports, there are other features RMM platforms offer to maximize the efficiency of your license management and monitoring. Here are some key considerations when utilizing RMM automation to track SaaS licenses.
Tracking inactive SaaS licenses through license usage reports
RMM platforms can help identify unutilized licenses for deallocation or reassignment to other users. Since SaaS licenses are usually paid through subscriptions, underutilized licenses waste budget over time. By having the ability to quickly identify and reclaim inactive licenses, organizations can reduce long-term SaaS costs.
Data retention to support trend analysis
Administrators can leverage RMM platforms to periodically generate longitudinal reports regarding SaaS usage, whether weekly or monthly. Retaining SaaS usage snapshots for 6 to 12 months can help improve trend analysis within an environment. Longer data retention times provide deeper insights regarding license usage patterns, helping justify licensing decisions.
Security considerations
Even though RMMs provide incredible monitoring capability, administrators should avoid over-collecting sensitive data that can violate end-user privacy. For instance, over-collecting personal data, like browser history, can break General Data Protection Regulation (GDPR) compliance.
Working around API limits
APIs can only collect a certain amount of usage data within a timeframe, ranging from minutes to a day. Hitting these rate limits can cause scripts to fail, rendering license usage reports incomplete. As a workaround, use batch queries or schedule jobs during off-peak hours to maximize throughput and speed up bulk API queries.
NinjaOne services for SaaS license tracking and usage reports
Administrators can leverage the following NinjaOne services to make SaaS license tracking and inventory easier:
| NinjaOne service | Definition | How it helps with SaaS license tracking |
| Script scheduling | NinjaOne supports task scheduling for automated script execution. | Schedule script deployments to regularly collect endpoint license usage and activity data. |
| Alerting | Quickly notifies administrators whenever an endpoint meets a specific condition. | Set notifications for automated detection when SaaS licenses are unused after a specified period. |
| Custom reports | This feature allows the creation of customizable reports using templates while streamlining report creation through scheduled delivery. | Generate recurring license usage reports automatically for M65, Zoom, Adobe, and other SaaS applications for easy tracking and monitoring. |
| Asset inventory | Provides a detailed view of installed endpoint software, all within a single pane of glass. | A comprehensive view of IT assets helps with strategic license allocation across end users, boosting cost management practices. |
| Cross-platform support | Streamlines monitoring and management of endpoints using different operating systems, preventing the need for multiple, separate platforms. | Cross-platform endpoint monitoring and scripting make SaaS license tracking easier within mixed environments. |
| PSA integration | PSA software tracks business processes, including assets like SaaS license allocation and costs. | NinjaOne’s standalone PSA solution and integration with various PSA systems offer broad license tracking capabilities. |
Leverage RMM platforms to streamline SaaS license tracking
Tracking SaaS license usage helps MSPs and internal IT teams reduce costs due to oversubscription. Administrators can also schedule scripts using RMMs to automate audits, helping them spot underutilized licenses and minimize wasteful allocations. Through longitudinal reporting, data-backed trends can be detected over time, justifying licensing allocation strategies, such as renewal or removal.
Related topics:
