Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions docs/function-documentation/Get-VerkadaAccessEvents.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Returns Verkada Access Control events using https://apidocs.verkada.com/referenc
```
Get-VerkadaAccessEvents [[-org_id] <String>] [[-x_verkada_auth_api] <String>] [[-region] <String>]
[[-start_time] <DateTime>] [[-end_time] <DateTime>] [[-event_type] <String[]>] [[-side_id] <String[]>]
[[-device_id] <String[]>] [[-user_id] <String[]>] [-errorsToFile] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
[[-device_id] <String[]>] [[-user_id] <String[]>] [-toLocalTime] [-errorsToFile]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -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

Expand Down
12 changes: 10 additions & 2 deletions verkadaModule/Public/Get-VerkadaAccessEvents.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ','}
Expand All @@ -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] {
Expand Down
2 changes: 1 addition & 1 deletion verkadaModule/verkadaModule.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down