mbegan/Okta-PSModule

oktaListUsers to query users matching specific profile attribute values

Opened this issue · 7 comments

Hi,
I want to query all users with the profile.title value matching "some title".
I tried by using "oktaListUsers" like below but looks like it paginates but doesn't fetch anything:

oktaListUsers -oOrg prod1 -limit 1000 | Where {$_.profile.title -like "VP"}

I may not be doing it right.
Can you give me some pointers ? I tried using "get-help oktaListUsers" which isn't much of a help either.

Thanks,
Roy

We use the following to pull info out of the oktaListActiveUsers command.

(oktaListActiveUsers -oOrg prod1).profile | select firstname,lastname,email,employeenumber | export-csv c:\temp\oktausers1.csv

I am sure you could add a filter to where I have the select statement.

Out of curiosity, if this module still working for you? I am getting the below error message when running oktaGetUserbyID or really any command inside of this module/wrapper

WARNING: Unable to find type [Microsoft.PowerShell.Commands.HttpResponseException].
WARNING: Encountered error, returning limited or empty set

If use the connect-okta -token -fulldomain from the okta.core.automation module I can then run commandlets in this okta module. Really strange behavior and its doing the same thing on everyone's computers over here.

Same error here @CJChristensen . Did you find a fix for it by any chance?

@CJChristensen and @alexc307

I started getting "Unauthorized (401)" with this module. So I switched to the official PS module (okta.core.automation).

Has anyone found a fix for that issue with not being able to load that HttpResponseException type? I'm pretty good with PowerShell, but I'm not familiar with loading types....

So, Microsoft.PowerShell.Commands.Utility.dll apparently contains the HttpResponseException typ, so, when I try this:

add-type -Path "C:\Program Files\powershell\6\Microsoft.PowerShell.Commands.Utility.dll"

I get this:

add-type : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
At C:\ProgramData\Scripts\sync_ADgroups_to_Oktagroups_MO.ps1:6 char:1

  • add-type -Path "C:\Program Files\powershell\6\Microsoft.PowerShell.Commands.Util ...
  •   + CategoryInfo          : NotSpecified: (:) [Add-Type], ReflectionTypeLoadException
      + FullyQualifiedErrorId : System.Reflection.ReflectionTypeLoadException,Microsoft.PowerShell.Commands.AddTypeCommand
    
    

So, I'm probably not loading the correct type? I have upgraded to PS 6.1 on Windows Server 2012 R2.

So, I updated to powershell "core" version 6.1.0, loaded Visual Studio Code, installed the Powershell and vscode-icons extensions, reloaded VS Code, then needed to update the Settings (gear icon in lower left) / Workspace Settings / PowerShell Configuration / Power Shell Exe Path to C:\Program Files\PowerShell\6\pwsh.exe and reload Powershell. Updated version shows up now:

PS C:\ProgramData\Scripts> $psversiontable

Name Value


PSVersion 6.1.0
PSEdition Core
GitCommitId 6.1.0
OS Microsoft Windows 6.3.9600
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

However, the new PS version no longer references the folder where the Okta module has been, so I'll need to move it to a different path -- but, at least, no longer running into that type issue any longer:

Import-Module : The specified module 'Okta' was not loaded because no valid module file was found in any module directory.
At C:\ProgramData\Scripts\sync_ADgroups_to_Oktagroups_MO.ps1:16 char:5

  • Import-Module Okta
    
  • ~~~~~~~~~~~~~~~~~~
    
  • CategoryInfo : ResourceUnavailable: (Okta:String) [Import-Module], FileNotFoundException
  • FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

I copied the Okta module to c:\program files\powershell\6\modules\ -- worked.