mbegan / Okta-PSModule

Okta API Powershell Wrapper Module
Other
102 stars 31 forks source link

Can't seem to run the listUsersbyDate function using 'create' #9

Closed srshaw2211 closed 7 years ago

srshaw2211 commented 7 years ago

Hi there, Your scripts have been really useful. I have had a problem. I can successfully run

$users = oktaListUsersbydate -oOrg prod -status DEPROVISIONED -field lastUpdated -operator gt -date "2016-11-17T00:00:00.000Z"

for example. But if I change the code so it uses created as I am trying to get lists of users created since say yesterday I get a format error.
Is this a known issue please? I have tried it and it just doesn't like lastUpdated being replaced with created.

Would be great if you get the time to have a look at it for me. thanks

mbegan commented 7 years ago

Hi There, there is a limit to the fields that are actually indexed on the Okta side.

I know they are actively working to expand the capabilities in this area and there is an EA (early access) feature but i've not had a chance to dig into it. When it hits GA i'll certainly amend the functions to leverage it.

What I would suggest doing to overcome this now is to grab all the users and filter as much as you can (last updated is still a meaningful attribute as well as status) and pull them into a powershell array and iterate through the array doing a date comparison against the created field.

something like this

$today = Get-Date
$yesterday = $today.AddDays(-1)

$users = oktaListUsersbydate -oOrg prod -status ACTIVE -field lastUpdated -operator gt -date $yesterday

foreach ($user in $users)
{
    if ($user.created -gt $yesterday)
    {
        Write-Host $user.profile.login was created after $yesterday see $user.created
    }
}
srshaw2211 commented 7 years ago

Thanks Matt

That's a great suggestion. I shall try it . Thanks for your help .

Regards

Stephanie

Sent from my iPhone

On 18 Nov. 2016, at 1:04 pm, Matt Egan notifications@github.com wrote:

Hi There, there is a limit to the fields that are actually indexed on the Okta side.

I know they are actively working to expand the capabilities in this area and there is an EA (early access) feature but i've not had a chance to dig into it. When it hits GA i'll certainly amend the functions to leverage it.

What I would suggest doing to overcome this now is to grab all the users and filter as much as you can (last updated is still a meaningful attribute as well as status) and pull them into a powershell array and iterate through the array doing a date comparison against the created field.

something like this

$users = oktaListUsersbydate -oOrg prod -status ACTIVE -field lastUpdated -operator gt -date "2016-11-17T00:00:00.000Z"

$today = Get-Date $yesterday = $today.AddDays(-1)

foreach ($user in $users) { if ($user.created -gt $yesterday) { Write-Host $user.profile.login was created after $yesterday see $user.created } } — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.