-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Description
# Use SSWS token instead of access token.
$Configuration = Get-OktaConfiguration
$Configuration.BaseUrl = 'https://YOURORG.okta.com'
$Configuration.DefaultHeaders = @{authorization = 'SSWS ...'}
Get-OktaUser me
New-OktaUser @{
profile = @{
firstName = 'Okta'
lastName = 'CLI'
login = 'oktacli@example.com'
email = 'EXAMPLE@gmail.com'
}
}
# To get pagination to work is a little wonky using the example in the README.
# https://github.com/okta/okta-powershell-cli#list-users-with-pagination
$page = Invoke-OktaListUsers -WithHttpInfo -Filter 'profile.lastName eq "Doe"'
$users = $page.response
foreach ($user in $users) {
write-host $user.id $user.profile.login
}
While ($page.NextPageUri) {
# This time you can pass the absolute Uri with already contains query params such as "limit" and/or "after".
$page = Invoke-OktaListUsers -Uri $page.NextPageUri -withHttpInfo
$users = $page.response
# have to repeat this loop from above....
foreach ($user in $users) {
write-host $user.id $user.profile.login
}
}
# Using splatting is less redundant and more elegant (imho). this is how i did it in my pwsh module, too.
# based on https://github.com/gabrielsroka/OktaAPI.psm1#usage
$params = @{WithHttpInfo = $true; Filter = 'profile.lastName eq "Doe"'}
do {
$page = Invoke-OktaListUsers @params
$users = $page.response
foreach ($user in $users) {
write-host $user.id $user.profile.login
}
# This time you can pass the absolute Uri which already contains query params such as "limit" and/or "after".
$params = @{uri = $page.NextPageUri; WithHttpInfo = $true}
} while ($page.NextPageUri)Metadata
Metadata
Assignees
Labels
No labels