Automate Workspace ONE Intelligence Reporting via REST API with PowerShell and Python

Targoon Siripanichpong
5 min readMar 7, 2023

--

As you have started deploying your devices with Workspace ONE, one aspect you will most likely work on is reporting and auditing. Whether it is a report on your current device deployments to monitor your fleets or a report on the real-time application deployment progress, Workspace ONE Intelligence reporting is the most flexible and scalable solution for endpoint reporting.

If you are not familiar with Workspace ONE Intelligence, you can find a great deep-dive operational tutorial in this TechZone article. Aside from the reporting component, you will have a chance to familiarize yourself with Dashboards for data visualization, Workflows for task automation, and Digital Employee Experience Management solutions (DEX) to help you proactively manage your user experience across all devices and platforms.

For now, we will focus on the reporting component of Workspace ONE Intelligence. Over the past year, many customers have asked how Workspace ONE Intelligence can be integrated with other data warehouse and analytics solutions, and more specifically, how customers can automatically pull data from Workspace ONE Intelligence into a data warehouse solution for inventory or analytics. This is where Workspace ONE Intelligence API comes in. With Intelligence API, we can script the end-to-end process, starting with running a report, downloading, and saving the report to a targeted output path. I have created an example API script for you to leverage, in PowerShell and Python.

This TechZone article walks through step-by-step how Workspace ONE Intelligence Reporting API works. I may rehash some of the concepts in this blog, but I will also add additional content, specifically on the scripting side. If you are pulling in Workspace ONE Intelligence reports into PowerBI, I would also recommend you check out Arsen’s post here for the integration walkthrough.

Here are the high-level steps to leverage the scripts. We will dive through each step in detail:

1. Generate a Workspace ONE Intelligence Service Account

2. Create a report and share it with the Service Account. Alternately, we can leverage the API to create a report, but I find it easier to use the UI to create a report rather than building it through API. Though there are benefits to generating the report using the API, this is out of the scope of this post.

3. Obtain the report ID

4. Run the script from the command line interface

Generating Workspace ONE Intelligence Service Account

Under Accounts > Service Accounts, click ADD.

Name the Service Account. Click on GENERATE CLIENT SECRET.

The Service Account will then be generated, along with the client ID and client secret. The JSON file will also be generated, containing the same information as well. The client ID and client secret will be used in the authentication process.

Create a report and share it with the Service Account

Follow the steps here to create a report. Once the report is created, share the report with the Service Account. This will allow the Service Account to pull the report via API.

Obtain the report ID

Once you create the report, the report ID can be found in the URL. This value will be passed along in the script to identify which report we would like to download.

Once these steps are completed, you are ready to run the script!

Run the script from the command line interface

You can download the sample scripts from developer.vmware.com. The scripts are in both Python and Powershell, depending on your preferred scripting languages. For both scripts, the following parameters are used:

  • Region — Workspace ONE Intelligence API region (e.g., na1, ca1, sandbox, etc). More information here — Intelligence URL by Region.
  • ReportId — Existing Workspace ONE Intelligence report ID
  • ClientId — Client ID of the service account
  • ClientSecret — Client Secret of the service account
  • OutFile — Targeted output file path & file name

Example (Python):

python3 IntelligenceReportDownload.py -Region “sandbox” -ReportId “XXX” -ClientId “XXX” -ClientSecret “XXX” -OutFile “device_report.csv”

Example (Powershell):

.\Intelligence_report_download_ps.ps1 -Region “sandbox” -ReportId “XXX” -ClientId “XXX” -ClientSecret “XXX” -OutFile “device_$(Get-Date -Format “yyyyMMddHHmmss”).csv”

Here are the steps being executed in the scripts:

  1. get_access_token(): This function generates an access token using the client ID and client secret provided through the command-line interface. The access token will be used throughout the script to make the necessary API calls.
  2. run_report(): This function runs the report specified by the report ID provided through the command-line interface.
  3. get_report_list(): This function retrieves the list of all available reports for download.
  4. download_report(): This function downloads the latest available report from the list of available reports.
  5. save_report(): This function saves the downloaded report as a CSV file with the name provided through the command-line interface.

That’s about it! You can run the scripts ad-hoc or run them on a scheduled basis using a scheduler or a cron job. You can also modify the script to write the result directly to your data warehouse solution instead of outputting a CSV file. At the very least, I am hoping this would give you another tool to pull your Workspace ONE data to be used in other systems.

Additional Resources

I would also recommend you check out the following resources around Workspace ONE Intelligence.

--

--

Targoon Siripanichpong

Sr. Customer Success Manager for VMware — focusing on End-User Computing. A dog dad.