Photo by Pixabay on


You might have to kill Okta session of large number of users in a go, you can use this script to perform the same.

Also, this script could be a starting point to invoke many API Methods for different purpose. You can save this as a .ps1 or go to my github url to download the script and input csv file.

You would have to put email address and uid of end users in csv file. You can get this from okta reports.

API Documentation

Script Download


#Force request to be sent via TLS1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

#Input file, contains user email address and okta UID

$ImportFile = import-csv "$home\Desktop\user.csv"
$UserID = $ImportFile.uid

#Constuct Headers
$Output = @()
foreach ($userids in $ImportFile) {
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Accept", "application/json")
$headers.Add("Content-Type", "application/json")
#$headers.Add("Authorization", "SSWS Paste_Okta_Token")
$headers.Add("Authorization", "SSWS 00Y8rfTVL0iBuWOqxntuiD3FjqQwJMJh6nqT1NsfDC")

# Construct URL for request
$start = ""
$user = $userids.uid
$end = "/sessions"
$url = $start + $user + $end
write-host ($url + " request sent for " + $ -ForegroundColor Green

# Actual Changes
$response = Invoke-RestMethod $url -Method 'DELETE' -Headers $headers -Body $body

#$response | ConvertTo-Json
$Output +=$response

Thank you for you time !