For Flexera One customers using IT Visibility with Technology Intelligence Platform (TIP), it can be tricky to create and run GraphQL queries against your TIP data. To help you simplify interactions with the GraphQL API and accelerate automation across ITAM and ITSM-related tasks, Flexera provides PowerShell cmdlets that make it easier for you to query your Technology Intelligence Platform data via the GraphQL API.
With these cmdlets, you can authenticate once, and then easily run queries, page through results, consume results in PowerShell, and export consistent JSON-style output.
Prerequisites
The following prerequisites apply to customers who want to use the GraphQL Cmdlets.
- Supported OS and Architecture
- .Net 8.0 or higher
- PowerShell 7.4 or greater
- API credentials for Flexera One
- Network access to GraphQL API endpoints
If you have the prerequisite platform, software, network access, and credentials, see the Downloads section below to obtain a ZIP archive appropriate for your system.
Downloads
The cmdlets are available as ZIP archives specific to your platform: Windows, Mac, or Linux. Select the link below to download the ZIP file appropriate for your platform.
- Windows: Flexera.GraphQL.Cli-win-x64-1.0.0-signed.zip
- Mac: Flexera.GraphQL.Cli-osx-arm64-1.0.0-signed.zip
- Linux: Flexera.GraphQL.Cli-linux-x64-1.0.0-signed.zip
Installation and verification steps
- Download the ZIP archive appropriate for your machine’s platform: Windows, Mac, or Linux.
- Extract the contents of the archive.
- In the resulting folder, find
Flexera.GraphQL.Cli.dlland import the module:
Import-Module ./Flexera.GraphQL.Cli.dll
- Verify the module was successfully imported:
Get-Module Flexera.GraphQL.Cli
If successful, the result of the Get-Module command looks like this:
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Binary 1.0.0.0 Flexera.GraphQL.Cli Invoke-GraphQLQuery
NOTE: For the latest guidance, use the cmdlets’ built-in Help command. For example: Invoke-GraphQLQuery -Help
Authentication and initial setup
After downloading and installing the cmdlets, you can authenticate and verify that your refresh token is valid. Follow the steps below to get your refresh token, orgId, and zone ready before issuing the Login command. Then use the Login command again, this time with the -VerifyRefreshToken option, to confirm you are properly authenticated.
To authenticate with Flexera One
- Obtain a refresh token from your account’s User Settings section in Flexera One. See Generating a Refresh Token in the Flexera One help library for instructions.
- Copy your refresh token and have the value ready to use when you issue the login command.
- Have your organization’s orgId ready. Your orgId appears in the URL when you are signed in to Flexera One.
- For example, when you are on the Flexera One landing page, you can find it here: https://app.flexera.com/orgs/your-orgId/landing
- Be prepared to identify your Zone. Zones can be NAM, EU, or AU. For a list of currently valid zones, use:
Invoke-GraphQLQuery -Login -ListZones
- Execute a Login command using the refresh token, orgId, and zone values as shown below:
Invoke-GraphQLQuery -Login -SetRefreshToken "your-refresh-token" -SetOrganization "your-orgId" -SetZone "your-zone"
To verify you are properly authenticated
-
Execute a Login command with only the -VerifyRefreshToken option as shown here:
Invoke-GraphQLQuery -Login -VerifyRefreshToken
- When successful, the response is:
Refresh token is valid.
NOTE: For the latest guidance, use the cmdlets’ built-in Help command. For example: Invoke-GraphQLQuery -Help
Supported query formats and output options
With the GraphQL Cmdlets you can run queries in two ways:
- By supplying them as a string in the command line and using the
-Executeoption. - By supplying a valid query file and using the
-ExecuteFileoption.
TIP: Use (limit: n), for example (limit: 10), for queries you are testing to limit the results set.
Running a query from a string
To run a query from a string, you can either define the query in a string or enclose it in quotation marks directly in the command statement. Here’s an example that defines the query as a string, stores the query results in a variable, and then writes out the value of that variable:
# Define your GraphQL query in a string
$query = "query { devices { id name manufacturer { name description } } }";
# Run a sample query
$result = Invoke-GraphQLQuery -Query -Execute $query
# Output the result
Write-Output $result
Running a query from a file
To run a query from a file, define the path to your query file instead:
# Define the path to your query file $queryFilePath = "path\to\your\query.json"
# Run a sample query from file $result = Invoke-GraphQLQuery -Query -ExecuteFile $queryFilePath
# Output the result Write-Output $result
Sample query file "query":
"query { devices { id name } }"
Examples and usage scenarios
- To execute a GraphQL query directly from the command line, use the following command:
Invoke-GraphQLQuery -Query 'GraphQL query string' -OutFile 'optional-output-file'
Example:
Invoke-GraphQLQuery -Query 'query { devices { id name } }'
- To execute a GraphQL query from a file, use the following command:
Invoke-GraphQLQuery -Query -ExecuteFile 'path-to-query-file' -OutFile 'optional-output-file'
Example:
Invoke-GraphQLQuery -Query -ExecuteFile 'C:\\Queries\\getDevices.json'
Query file content format
{ "query": "GraphQL-query-string" }
Example queries
- Simple Query: Retrieve a list of all devices with their ID and name
query { devices { id name } }
- Nested Query: Retrieve a list of all devices with their ID, name, and the manufacturer’s name and description
query { devices { id name manufacturer { name description } } }
- Paginated Query: Retrieve device IDs & names for the second page of results (records 101‑200)
query { devices ( limit:100 offset:100 ) { id name } }
- Filtered Query: Retrieve outdated devices in inventory
query { devices ( where: { lifecycle: { isObsoleteDateExpired: { eq: true } } } ){ name lifecycle { obsoleteDate isObsoleteDateExpired } } }
- Aggregated Query: Device count by manufacturer
query { devices@distinct { manufacturerName deviceCount:id@count } }
TIP: Consider using the limit parameter to reduce the output size. For example, to limit to 20 records use: Invoke-GraphQLQuery -Query -Execute "query { devices (limit: 20) {id name manufacturer { name description } } }"
For the latest guidance and additional usage scenarios, use the cmdlets built-in Help and Examples commands:
Invoke-GraphQLQuery -Help
Invoke-GraphQLQuery -Examples
Related Articles
GraphQL query API permission error: insufficient privilege 14Number of Views PowerShell cmdlet get-property Used in a Custom Action 6Number of Views Integrate Flexera One ITAM data with ReportsExecute REST API 22Number of Views SQL queries for the csv files in the Results folder in Data Platform 6Number of Views How to view application data in Snow License Manager that comes from a connector 14Number of Views
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add Additional feedback ( Optional )
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
Case id: 00001065
Activity: Status change: 2 hours ago