Using PowerShell with the new v2 ZOOM API


I tend to use PowerShell for most of my admin activities so when I started getting requests to automate things for Zoom I didn’t see any reason to change.  

Requiring a JWT token was a little bit of a challenge in PS but since I took the time to figure it out I thought I would share it here.

The function to create a token is:

function Get-ZoomToken
Create a JWT token using HMAC-256
Create a JWT token using HMAC-256 for use with the ZOOM version 2 API
Get-ZoomToken -api_key <zoom api key> -api_secret <zoom api key secret>
Anthony Brown (
[int]$timeout = 15

Sadly, the easiest way to get these DLLs is to create a new VS project and install Microsoft.IdentityModel.Tokens

and System.IdentityModel.Tokens.Jwt packages via NuGet and then copy them out of the packages <navigate to correct .NET version>

folder under your VS project directory.

$null = [System.Reflection.Assembly]::LoadFrom(“C:\PS Script\MyAssemblies\Microsoft.IdentityModel.Tokens.dll”)
$null = [System.Reflection.Assembly]::LoadFrom(“C:\PS Script\MyAssemblies\System.IdentityModel.Tokens.Jwt.dll”)

$SecurityKey = [Microsoft.IdentityModel.Tokens.SymmetricSecurityKey]::new([System.Text.Encoding]::UTF8.GetBytes($api_secret))
$credentials = [Microsoft.IdentityModel.Tokens.SigningCredentials]::new($SecurityKey, [Microsoft.IdentityModel.Tokens.SecurityAlgorithms]::HmacSha256)

$header = [System.IdentityModel.Tokens.Jwt.JwtHeader]::new($credentials)
$payload = [System.IdentityModel.Tokens.Jwt.JwtPayload]::new()

$payload.Iss = “$api_key”
$payload.Exp = (Get-Date).AddMinutes($timeout).ToFileTime().ToString()

$secToken = [System.IdentityModel.Tokens.Jwt.JwtSecurityToken]::new($header, $payload)
$handler = [System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler]::new()

$token = $handler.WriteToken($secToken)


An example of using the token to pull a list of zoom users may look like this:

function Get-ZoomUsers
$headers = @{“Authorization” = “Bearer $token”}

$BaseUri = ‘

$page_number = 1
$page_count = 1

$Users = @()

Uri = "($BaseUri)?page_size=200&page_number=$page_number"

$UserList = Invoke-RestMethod -Method Get -Uri $Uri -Headers $headers

$Users += $UserList.users


Sleep -Seconds .2
until ($page_number -gt $UserList.page_count)


I hope this is helpful.


Hello, you can set the JWT expiration time a little longer, so you don’t need to get JWT token every time. 


thanks for sharing


Very helpfull! Thanks!