Software Inventory Script
Automatically collect and upload installed software to FreeITSM
What This Script Does
This PowerShell script collects installed software information from a Windows machine using UninstallView by NirSoft and uploads it to the FreeITSM Software Inventory API. You can deploy it via Group Policy, SCCM, a scheduled task, or any other method you use to run scripts across your estate.
Prerequisites
- UninstallView: Download from NirSoft and extract to a folder on each machine (e.g.
C:\software\uninstallview) - API Key: Generate one in FreeITSM under Software → Settings
- PowerShell: Version 5.1 or later (included with Windows 10/11 and Server 2016+)
How It Works
- 1 Runs UninstallView to export installed software as JSON
- 2 Wraps the data with the machine hostname
- 3 Saves a local copy for auditing (optional)
- 4 Sends the payload to the FreeITSM API
The Script
Copy the script below and save it as Submit-SoftwareInventory.ps1. Update the configuration variables at the top with your FreeITSM URL, API key, and the path to UninstallView.
<# This script collects installed software inventory information from a Windows system and uploads it to the FreeITSM Software Inventory API. REQUIREMENTS: - UninstallView by NirSoft must be installed: https://www.nirsoft.net/utils/uninstall_view.html UninstallView is used to generate a JSON file containing installed software details, which is then wrapped with hostname information and submitted to the FreeITSM API. AUTHENTICATION: - The Authorization key must be generated in the FreeITSM platform under: Software -> Settings #> # ========================= # FreeITSM API CONFIGURATION # ========================= # API endpoint for software inventory submission # Example: # https://your.itsm.com/api/external/software-inventory/submit $ApiUrl = "https://your.itsm.com/api/external/software-inventory/submit" # Authorization key generated in FreeITSM under Software -> Settings $AuthorizationKey = "REPLACE_WITH_YOUR_API_KEY" # ========================= # LOCAL PATH CONFIGURATION # ========================= # Base folder where UninstallView is located $BasePath = "C:\software\uninstallview" # Path to uninstallview.exe $ExePath = Join-Path $BasePath "uninstallview.exe" # UninstallView output file $SourceJson = Join-Path $BasePath "appwiz.json" # Local copy of the final payload (optional, for troubleshooting/auditing) $OutputJson = Join-Path $BasePath "inventory.json" # ========================= # 1. GENERATE SOFTWARE INVENTORY # ========================= Write-Host "Generating software inventory JSON..." if (-not (Test-Path $ExePath)) { Write-Error "Cannot find uninstallview.exe at: $ExePath" exit 1 } # Run UninstallView and export installed software as JSON & $ExePath /sjson $SourceJson if (-not (Test-Path $SourceJson)) { Write-Error "JSON file was not generated by uninstallview.exe" exit 1 } # ========================= # 2. PREPARE JSON PAYLOAD # ========================= $hostname = $env:COMPUTERNAME $jsonContent = Get-Content -Path $SourceJson -Raw $data = $jsonContent | ConvertFrom-Json # Ensure Software is always a proper PowerShell array $softwareArray = @($data) # Build the payload expected by FreeITSM $newRoot = [PSCustomObject]@{ Hostname = $hostname Software = $softwareArray } # Convert to clean JSON $jsonData = $newRoot | ConvertTo-Json -Depth 12 # ========================= # 3. SAVE LOCAL COPY (OPTIONAL) # ========================= $jsonData | Set-Content -Path $OutputJson -Encoding UTF8 # ========================= # 4. SEND DATA TO FREEITSM API # ========================= # Convert JSON to real UTF-8 byte array $utf8Bytes = [System.Text.Encoding]::UTF8.GetBytes($jsonData) $headers = @{ "accept" = "application/json" "Authorization" = $AuthorizationKey } $response = Invoke-RestMethod ` -Uri $ApiUrl ` -Method Post ` -Body $utf8Bytes ` -Headers $headers ` -ContentType "application/json; charset=utf-8" Write-Host "API Response:" $response | ConvertTo-Json -Depth 5
Configuration
Before running the script, update these three variables at the top:
- $ApiUrl – Your FreeITSM instance URL followed by
/api/external/software-inventory/submit - $AuthorizationKey – The API key generated in Software → Settings
- $BasePath – The folder where you've extracted UninstallView
Deployment Tips
- Scheduled Task: Run daily or weekly to keep inventory current
- Group Policy: Deploy as a startup or logon script across your domain
- SCCM/Intune: Package as a script deployment for managed devices
- Manual: Run on individual machines as needed for ad-hoc audits