Software Install List of Devices Using PowerShell

Use a PowerShell script to retrieve a list of devices that have a unique software package installed. This list includes the version number on the export file, but the search is done using the software package name.

This example output uses a search for Microsoft Edge Chromium:

There are four areas in the code that you’ll need to update to get the script to function:

  1. $orgID = 'YOUR_ORG_ID'
    You will need your Org ID, which can be found by looking at the URL. Select the value after the "?o="

    Note: The user must be a Global or Zone administrator to manage API keys for a zone. See Managing Keys for more information.

  2. $apiKey = 'YOUR_API_KEY'
    In your console, go to Settings > Keys and select the API key. Note that the API key is per user, so that another user will have different API keys.
  3. $filePath 
    You can also modify $filepath if you want to change the file name or save it in a different location. Keep in mind the script will overwrite a previously generated file if it exists.
  4. $appInstalled = 'APPLICATION' 
    Enter the name of the application as it is listed in the software section of a device’s page that has it installed.

Software List of Devices Script

Use this script to pull an inventory of devices that have a unique software package installed.

$apiKey = 'YOUR_API_KEY'
$orgID = 'YOUR_ORG_ID'

$appInstalled = 'Microsoft Edge'
$filepath = 'C:\Temp\AppInstalled.csv'

Set-Content $filepath -Value "Computer,Name,Version"

$apiInstance = ''
$apiTable = 'servers'
$orgAndKey = "?o=$orgID&api_key=$apiKey"

# Put components together
$getURI = $apiInstance + $apiTable + $orgAndKey

# Get the json body of the Web Request
$jsonReturn = (Invoke-WebRequest -UseBasicParsing -Method Get -Uri $getURI).Content

# Convert to object with manipulatable properties/values
$servers = $jsonReturn | ConvertFrom-Json
$servers = $servers | Sort-Object name

# Check each server for software
foreach ($server in $servers) {

    $serverID = $
    $serverName = $
    $orgAndKey = "/$serverID/packages?o=$orgID"

    # Put components together
    $getURI = $apiInstance + $apiTable + $orgAndKey

    $headers = @{ "Authorization" = "Bearer $apiKey" }
    $response = (Invoke-WebRequest -Method Get -Uri $getURI -Headers $headers).Content | ConvertFrom-Json

    $installed = $response | Where-Object {$_.installed -EQ $true -and $_.display_name -EQ $appInstalled}

    $output = $serverName + "," + $installed.display_name + "," + $installed.version
    $output | Add-Content -Path $filepath


Related Topics: