Skip to content

Instantly share code, notes, and snippets.

@MatthewJDavis
Created April 5, 2021 21:59
Show Gist options
  • Select an option

  • Save MatthewJDavis/09d07967dbc587b9b684776284ae555c to your computer and use it in GitHub Desktop.

Select an option

Save MatthewJDavis/09d07967dbc587b9b684776284ae555c to your computer and use it in GitHub Desktop.
Use PowerShell to get the members of an Okta group
# Returns the login names of all the user in a specified Okta group.
# Requires an API token to be generated: https://developer.okta.com/docs/guides/create-an-api-token/overview/
$apiToken = Get-Secret -Name 'okta-api-token'
$oktaUri = 'example-admin.okta.com'
$groupId = ''
$uri = "https://$oktaUri/api/v1/groups/$groupId/users"
$headers = @{
'Authorization' = "SSWS $apiToken"
}
$response = Invoke-RestMethod -Uri $uri -Headers $headers
foreach($r in $response){
$r.profile.login.Split('@')[0]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment