From fd9a5ee62a3847a1754f5185a9ad47a0d17ea687 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Tue, 30 Sep 2025 15:26:34 -0500 Subject: [PATCH 1/2] Adds local time conversion to access events Adds a parameter to convert access event timestamps to local time. The function now converts timestamps from UTC to local time based on the new `-toLocalTime` switch parameter. This improves usability by presenting timestamps in the user's local timezone. It also converts start and end times to universal time to align correctly with the API. --- verkadaModule/Public/Get-VerkadaAccessEvents.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/verkadaModule/Public/Get-VerkadaAccessEvents.ps1 b/verkadaModule/Public/Get-VerkadaAccessEvents.ps1 index 9a74f51..c66d107 100644 --- a/verkadaModule/Public/Get-VerkadaAccessEvents.ps1 +++ b/verkadaModule/Public/Get-VerkadaAccessEvents.ps1 @@ -52,6 +52,9 @@ function Get-VerkadaAccessEvents{ #The optional user_id/s for the events [Parameter()] [string[]]$user_id, + #Switch to convert timestamps to local time + [Parameter()] + [switch]$toLocalTime, #Switch to write errors to file [Parameter()] [switch]$errorsToFile @@ -70,11 +73,11 @@ function Get-VerkadaAccessEvents{ $query_params = @{} if (!([string]::IsNullOrEmpty($start_time))){ - $start_time_epoch = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $start_time).TotalSeconds + $start_time_epoch = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $start_time.ToUniversalTime()).TotalSeconds $query_params.start_time = $start_time_epoch } if (!([string]::IsNullOrEmpty($end_time))){ - $end_time_epoch = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $end_time).TotalSeconds + $end_time_epoch = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $end_time.ToUniversalTime()).TotalSeconds $query_params.end_time = $end_time_epoch } if (!([string]::IsNullOrEmpty($event_type))){$query_params.event_type = $event_type -join ','} @@ -84,6 +87,11 @@ function Get-VerkadaAccessEvents{ try { $response = Invoke-VerkadaRestMethod $url $org_id $x_verkada_auth_api $query_params -body_params $body_params -method GET -pagination -page_size 200 -propertyName 'events' + if ($toLocalTime.IsPresent){ + foreach ($e in $response){ + $e.timestamp = (Get-Date -Date ($e.timestamp) -AsUTC).ToLocalTime() + } + } return $response } catch [Microsoft.PowerShell.Commands.HttpResponseException] { From 0ec413d27db4050c7cc598092bc6bb8a706b7ffd Mon Sep 17 00:00:00 2001 From: bepsoccer <26012546+bepsoccer@users.noreply.github.com> Date: Tue, 30 Sep 2025 21:36:58 +0000 Subject: [PATCH 2/2] Bumping release to 0.9.7 --- .../Get-VerkadaAccessEvents.md | 19 +++++++++++++++++-- verkadaModule/verkadaModule.psd1 | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/function-documentation/Get-VerkadaAccessEvents.md b/docs/function-documentation/Get-VerkadaAccessEvents.md index a15bf20..d7f1e4b 100644 --- a/docs/function-documentation/Get-VerkadaAccessEvents.md +++ b/docs/function-documentation/Get-VerkadaAccessEvents.md @@ -15,8 +15,8 @@ Returns Verkada Access Control events using https://apidocs.verkada.com/referenc ``` Get-VerkadaAccessEvents [[-org_id] ] [[-x_verkada_auth_api] ] [[-region] ] [[-start_time] ] [[-end_time] ] [[-event_type] ] [[-side_id] ] - [[-device_id] ] [[-user_id] ] [-errorsToFile] [-ProgressAction ] - [] + [[-device_id] ] [[-user_id] ] [-toLocalTime] [-errorsToFile] + [-ProgressAction ] [] ``` ## DESCRIPTION @@ -174,6 +174,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -toLocalTime +Switch to convert timestamps to local time + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -errorsToFile Switch to write errors to file diff --git a/verkadaModule/verkadaModule.psd1 b/verkadaModule/verkadaModule.psd1 index eca287b..6fd1270 100644 --- a/verkadaModule/verkadaModule.psd1 +++ b/verkadaModule/verkadaModule.psd1 @@ -12,7 +12,7 @@ RootModule = 'verkadaModule.psm1' # Version number of this module. -ModuleVersion = '0.9.6' +ModuleVersion = '0.9.7' # Supported PSEditions CompatiblePSEditions = 'Desktop', 'Core'