mbegan / Okta-PSModule

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

OktaListLogs issue #29

Closed zsirkin closed 4 years ago

zsirkin commented 5 years ago

Hey Matt, first off THANK YOU. I've used your module extensively and hopefully my issue is just scripting ignorance.
I'm trying to stick a variable into your Oktalistlogs command.

By design, with no variables, this would work fine (fake id/org of course): oktaListLogs -oOrg prod-filter 'target.id eq "00u1bv90d02Xx5nYc0h8"'

but this doesn't (even though the expanded variables' results visually would be the same).

$UID = ""00u1bv90d02Xx5nYc0h8"" $target = "`'target.id eq $UID'" $Logs = oktaListLogs -oOrg prod -sinceDaysAgo 1 -filter $target

results

VERBOSE: GET https://xxxxxx.okta.com/api/v1/logs?since=2019-01-12T11:24:51.180Z&filter='target.id eq "00u1bv90d02Xx5nYc0h8"' wit h 0-byte payload WARNING: Unable to find type [Microsoft.PowerShell.Commands.HttpResponseException]. WARNING: Encountered error, returning limited or empty set

I've written a libraries worth of scripts and a huge GUI based on your work...thank you! This is actually meant to be part of a the GUI so that a helpdesk person can choose a user, which gets converted into a UID, then choose the log type/days/results/whatever and perform log searches. Thanks again.

zsirkin commented 5 years ago

Sorry it should be: $UID = """00u1bv90d02Xx5nYc0h8""" I was missing an extra quote to give it the look of: "00u1bv90d02Xx5nYc0h8"

Still same problem persists of course.

mbegan commented 5 years ago

Hey Zach, Glad you've found this helpful, I know it was (and continues to be ) invaluable for me.

I think you are just running into some fun quoting and command expansion issues.

Okta doesn't want to see the single quote around the filter in the request but the single quote is needed by powershell to encase the filter when "typing" it out. If you turn the filter into a variable the single quotes aren't required anymore because of the way powershell expands the values.

Here is how i would do it (I'm using powershell core running on MacOS), give this a shot and let me know.

PS > $myId = "0oac95jqqv15gI8uj0h7"
PS > $myTarget = 'target.id eq "' + $myId + '"'
PS > $logs = oktaListLogs -sinceDaysAgo 1 -filter $myTarget -Verbose                                                                                                                                                    
VERBOSE: GET https://mattegantest.oktapreview.com/api/v1/logs?since=2019-01-13T16:57:05.585Z&filter=target.id eq "0oac95jqqv15gI8uj0h7" with 0-byte payload
Saikishore031 commented 4 years ago

Hi began,

Could you please help me with the below error. Capture

mbegan commented 4 years ago

Probably a tls 1.2 - take a look at the readme it has a section on troubleshooting TLS issues

Saikishore031 commented 4 years ago

Cool, Thanks alot it is working fine now πŸ‘ πŸ‘ πŸ‘