Created
April 5, 2021 21:59
-
-
Save MatthewJDavis/09d07967dbc587b9b684776284ae555c to your computer and use it in GitHub Desktop.
Use PowerShell to get the members of an Okta group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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