Skip to content

Get-OktaLogs changes the required date format for "since" and "until" query params #55

@laura-rodriguez

Description

@laura-rodriguez

The Logs API requires the format for date query params to be ISO8601 (i.e. 2024-10-21T16:24:13Z or Get-Date (Get-Date).ToUniversalTime() -UFormat '+%Y-%m-%dT%H:%M:%SZ'). The existing Get-OktaLogs cmdlet doesn't preserve formats, causing the API call to fail.
There are several routes we can explore to fix the issue:

  • Update the Cmdlet interface to receive strings instead of dates:
$until = $dateTo.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
$since = $dateFrom.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")

Get-OktaLogs -since $since -until $until
  • Keep the same Cmdlet interface but address the format internally
Get-OktaLogs -since $sinceUtcDate -until $untilUtcDate

//OktaSystemLogApi.ps1
// Assume $Since is already in UTC format
 if ($Since) {
            $LocalVarQueryParameters['since'] = $Since.ToString("yyyy-MM-ddTHH:mm:ssZ")
        }

We should update docs to show examples of how to use the logs cmdlets

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions