How to use Powershell with the Workspace ONE UEM API to search for users

Using API's has been infinitely helpful in integrating Workspace ONE UEM with other enterprise services and applications. A question was asked recently about forming the correct HTTP header using Powershell, and returning the users in the users. Below is an example Powershell script I was able to create for this example. Make sure to include base64 encoded credentials in a folder (c:\creds\b64.txt in the example), and to update the $apiKey variable with an API key.


#Workspace ONE UEM Environment Address / Authentication 
$addy = "https://ws1.molokaibank.com"
$b64 = Get-Content -Path "c:\creds\b64.txt"
$apiKey = "apikey"
$b64EncodedAuth = "$b64"

#Header
$content = "application/json" 
$authHeader = "Basic " + $b64EncodedAuth
$header = @{"Authorization" = $authHeader"aw-tenant-code" = $apiKey"Accept" = $content"Content-Type" = $content}

#Get Users from Workspace ONE API
$getUsers = Invoke-RestMethod -Uri "$addy/API/system/users/search" -Headers $header

$getUsers.Users 

When reviewing the results from the object with $getUsers.Users, the following is stored in the variable:




Mahalo,
Ryan Pringnitz

Comments

Popular posts from this blog

Delivering Managed Configurations (key/value pairs) to Android applications with Workspace ONE UEM profiles

Clean up duplicate identities and users from Workspace ONE using REST API's and PowerShell

How to use Square's OkHttp Java library to access Workspace ONE UEM API's