Skip to content

Instantly share code, notes, and snippets.

@1951FDG
Last active February 25, 2020 20:47
Show Gist options
  • Save 1951FDG/162859d0b3a2da2bbc4ecdfc2cfc69ae to your computer and use it in GitHub Desktop.
Save 1951FDG/162859d0b3a2da2bbc4ecdfc2cfc69ae to your computer and use it in GitHub Desktop.
Param
(
[Parameter(Mandatory=$true)][alias('org','OktaOrg')][string]$oOrg
)
$groups = oktaGetGroupsAll -oOrg $oOrg
foreach ($g in $groups)
{
if ($g.objectClass -eq 'okta:user_group')
{
$groupUsers = oktaGetGroupMembersbyId -oOrg $oOrg -gid $g.id -limit 200 -enablePagination $true
$toexport = New-Object System.Collections.ArrayList
foreach ($u in $groupUsers)
{
$line = [ordered]@{
email = $u.profile.email
login = $u.profile.login
firstName = $u.profile.firstName
lastName = $u.profile.lastName
oktaid = $u.id
}
$obj = New-Object psobject -Property $line
$_c = $toexport.Add($obj)
}
# $path = $home + '\Documents\WindowsPowerShell\Modules\Okta\' + $g.profile.name + '.csv'
$path = '\\tsclient\Okta-Scripts\\Okta\' + $g.profile.name + '.csv'
$toexport | Export-Csv -Path $path -NoTypeInformation
}
}
Param
(
[Parameter(Mandatory=$true)][alias('org','OktaOrg')][string]$oOrg
)
$users = oktaListUsers -oOrg $oOrg
$toexport = New-Object System.Collections.ArrayList
foreach ($u in $users)
{
$line = [ordered]@{
email = $u.profile.email
login = $u.profile.login
firstName = $u.profile.firstName
lastName = $u.profile.lastName
oktaid = $u.id
}
$obj = New-Object psobject -Property $line
$_c = $toexport.Add($obj)
}
#$path = $home + '\Documents\WindowsPowerShell\Modules\Okta\' + 'Everyone' + '.csv'
$path = '\\tsclient\Okta-Scripts\Okta\' + 'Everyone' + '.csv'
$toexport | Export-Csv -Path $path -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment