Define Okta API endpoint and API token
$oktaApiUrl = “https://your-okta-domain.okta.com/api/v1/users”
$apiKey = “your-api-key”
Create a new user
$userData = @{
profile = @{
firstName = “John”
lastName = “Doe”
email = “johndoe@example.com”
login = “johndoe@example.com”
}
credentials = @{
password = @{
value = “Password123!”
}
}
}
$userJson = $userData | ConvertTo-Json
Send a POST request to create the user
Invoke-RestMethod -Uri $oktaApiUrl -Headers @{ “Authorization” = “SSWS $apiKey” } -Method Post -Body $userJson -ContentType “application/json”