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

Zimperium Delivery and Activation on Android Enterprise with Workspace ONE UEM Product Provisioning

Setup Single Sign-On with Workspace ONE & ServiceNow (Mobile Flows Series - Part 1)

Digital Workspace Mobile Threat Detection & Response with Workspace ONE & Zimperium - Integrating zConsole