Skip to content

Commit ec62a27

Browse files
authored
Merge pull request #257 from bepsoccer/release
Adds Get-VerkadaAccessEvents function
2 parents 7fd7f60 + a1a8e6f commit ec62a27

File tree

4 files changed

+345
-8
lines changed

4 files changed

+345
-8
lines changed
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
---
2+
external help file: verkadaModule-help.xml
3+
Module Name: verkadaModule
4+
online version: https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Get-VerkadaAccessEvents.md
5+
schema: 2.0.0
6+
---
7+
8+
# Get-VerkadaAccessEvents
9+
10+
## SYNOPSIS
11+
Returns Verkada Access Control events using https://apidocs.verkada.com/reference/geteventsviewv1
12+
13+
## SYNTAX
14+
15+
```
16+
Get-VerkadaAccessEvents [[-org_id] <String>] [[-x_verkada_auth_api] <String>] [[-region] <String>]
17+
[[-start_time] <DateTime>] [[-end_time] <DateTime>] [[-event_type] <String[]>] [[-side_id] <String[]>]
18+
[[-device_id] <String[]>] [[-user_id] <String[]>] [-errorsToFile] [-ProgressAction <ActionPreference>]
19+
[<CommonParameters>]
20+
```
21+
22+
## DESCRIPTION
23+
Returns events for an organization within a specified time range.
24+
The org_id and reqired token can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands.
25+
26+
## EXAMPLES
27+
28+
### EXAMPLE 1
29+
```
30+
Get-VerkadaAccessEvents
31+
This will return all the access events from 1 hour in the past until present. The org_id and token will be populated from the cached created by Connect-Verkada.
32+
```
33+
34+
### EXAMPLE 2
35+
```
36+
Get-VerkadaAccessEvents -start_time 'January 1, 2025 9:00:00AM' -end_time 'February 8, 2025 10:30:00PM' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_auth_api 'sd78ds-uuid-of-verkada-token'
37+
This will return all the access events from Jan 1 at 9am to Feb 8 at 10:30pm. The org_id and token are submitted as parameters in the call.
38+
```
39+
40+
## PARAMETERS
41+
42+
### -org_id
43+
The UUID of the organization the user belongs to
44+
45+
```yaml
46+
Type: String
47+
Parameter Sets: (All)
48+
Aliases:
49+
50+
Required: False
51+
Position: 1
52+
Default value: $Global:verkadaConnection.org_id
53+
Accept pipeline input: True (ByPropertyName)
54+
Accept wildcard characters: False
55+
```
56+
57+
### -x_verkada_auth_api
58+
The public API token obatined via the Login endpoint to be used for calls that hit the public API gateway
59+
60+
```yaml
61+
Type: String
62+
Parameter Sets: (All)
63+
Aliases:
64+
65+
Required: False
66+
Position: 2
67+
Default value: $Global:verkadaConnection.x_verkada_auth_api
68+
Accept pipeline input: False
69+
Accept wildcard characters: False
70+
```
71+
72+
### -region
73+
The region of the public API to be used
74+
75+
```yaml
76+
Type: String
77+
Parameter Sets: (All)
78+
Aliases:
79+
80+
Required: False
81+
Position: 3
82+
Default value: Api
83+
Accept pipeline input: False
84+
Accept wildcard characters: False
85+
```
86+
87+
### -start_time
88+
The optional start time for the date range of events
89+
90+
```yaml
91+
Type: DateTime
92+
Parameter Sets: (All)
93+
Aliases:
94+
95+
Required: False
96+
Position: 4
97+
Default value: None
98+
Accept pipeline input: False
99+
Accept wildcard characters: False
100+
```
101+
102+
### -end_time
103+
The optional end time for the date range of events
104+
105+
```yaml
106+
Type: DateTime
107+
Parameter Sets: (All)
108+
Aliases:
109+
110+
Required: False
111+
Position: 5
112+
Default value: None
113+
Accept pipeline input: False
114+
Accept wildcard characters: False
115+
```
116+
117+
### -event_type
118+
The optional event type/s for the events
119+
120+
```yaml
121+
Type: String[]
122+
Parameter Sets: (All)
123+
Aliases:
124+
125+
Required: False
126+
Position: 6
127+
Default value: None
128+
Accept pipeline input: False
129+
Accept wildcard characters: False
130+
```
131+
132+
### -side_id
133+
The optional site_id/s for the events
134+
135+
```yaml
136+
Type: String[]
137+
Parameter Sets: (All)
138+
Aliases:
139+
140+
Required: False
141+
Position: 7
142+
Default value: None
143+
Accept pipeline input: False
144+
Accept wildcard characters: False
145+
```
146+
147+
### -device_id
148+
The optional device_id/s for the events
149+
150+
```yaml
151+
Type: String[]
152+
Parameter Sets: (All)
153+
Aliases:
154+
155+
Required: False
156+
Position: 8
157+
Default value: None
158+
Accept pipeline input: False
159+
Accept wildcard characters: False
160+
```
161+
162+
### -user_id
163+
The optional user_id/s for the events
164+
165+
```yaml
166+
Type: String[]
167+
Parameter Sets: (All)
168+
Aliases:
169+
170+
Required: False
171+
Position: 9
172+
Default value: None
173+
Accept pipeline input: False
174+
Accept wildcard characters: False
175+
```
176+
177+
### -errorsToFile
178+
Switch to write errors to file
179+
180+
```yaml
181+
Type: SwitchParameter
182+
Parameter Sets: (All)
183+
Aliases:
184+
185+
Required: False
186+
Position: Named
187+
Default value: False
188+
Accept pipeline input: False
189+
Accept wildcard characters: False
190+
```
191+
192+
### -ProgressAction
193+
{{ Fill ProgressAction Description }}
194+
195+
```yaml
196+
Type: ActionPreference
197+
Parameter Sets: (All)
198+
Aliases: proga
199+
200+
Required: False
201+
Position: Named
202+
Default value: None
203+
Accept pipeline input: False
204+
Accept wildcard characters: False
205+
```
206+
207+
### CommonParameters
208+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
209+
210+
## INPUTS
211+
212+
## OUTPUTS
213+
214+
## NOTES
215+
216+
## RELATED LINKS
217+
218+
[https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Get-VerkadaAccessEvents.md](https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Get-VerkadaAccessEvents.md)
219+

docs/reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* [Get-VerkadaAccessDoorConfigReport](function-documentation/Get-VerkadaAccessDoorConfigReport.md)
2323
* [Get-VerkadaAccessDoors](function-documentation/Get-VerkadaAccessDoors.md)
2424
* [Get-VerkadaAccessDoorSchedules](function-documentation/Get-VerkadaAccessDoorSchedules.md)
25+
* [Get-VerkadaAccessEvents](function-documentation/Get-VerkadaAccessEvents.md)
2526
* [Get-VerkadaAccessGroup](function-documentation/Get-VerkadaAccessGroup.md)
2627
* [Get-VerkadaAccessLevels](function-documentation/Get-VerkadaAccessLevels.md)
2728
* [Get-VerkadaAccessSite](function-documentation/Get-VerkadaAccessSite.md)
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
function Get-VerkadaAccessEvents{
2+
<#
3+
.SYNOPSIS
4+
Returns Verkada Access Control events using https://apidocs.verkada.com/reference/geteventsviewv1
5+
6+
.DESCRIPTION
7+
Returns events for an organization within a specified time range.
8+
The org_id and reqired token can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands.
9+
10+
.LINK
11+
https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Get-VerkadaAccessEvents.md
12+
13+
.EXAMPLE
14+
Get-VerkadaAccessEvents
15+
This will return all the access events from 1 hour in the past until present. The org_id and token will be populated from the cached created by Connect-Verkada.
16+
17+
.EXAMPLE
18+
Get-VerkadaAccessEvents -start_time 'January 1, 2025 9:00:00AM' -end_time 'February 8, 2025 10:30:00PM' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_auth_api 'sd78ds-uuid-of-verkada-token'
19+
This will return all the access events from Jan 1 at 9am to Feb 8 at 10:30pm. The org_id and token are submitted as parameters in the call.
20+
#>
21+
[CmdletBinding(PositionalBinding = $true)]
22+
[Alias("Get-VrkdaAcEvnts","gt-VrkdaAcEvnts")]
23+
param (
24+
#The UUID of the organization the user belongs to
25+
[Parameter(ValueFromPipelineByPropertyName = $true)]
26+
[ValidateNotNullOrEmpty()]
27+
[ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')]
28+
[String]$org_id = $Global:verkadaConnection.org_id,
29+
#The public API token obatined via the Login endpoint to be used for calls that hit the public API gateway
30+
[Parameter()]
31+
[ValidateNotNullOrEmpty()]
32+
[String]$x_verkada_auth_api = $Global:verkadaConnection.x_verkada_auth_api,
33+
#The region of the public API to be used
34+
[Parameter()]
35+
[ValidateSet('api','api.eu','api.au')]
36+
[String]$region='api',
37+
#The optional start time for the date range of events
38+
[Parameter()]
39+
[datetime]$start_time,
40+
#The optional end time for the date range of events
41+
[Parameter()]
42+
[datetime]$end_time,
43+
#The optional event type/s for the events
44+
[Parameter()]
45+
[string[]]$event_type,
46+
#The optional site_id/s for the events
47+
[Parameter()]
48+
[string[]]$side_id,
49+
#The optional device_id/s for the events
50+
[Parameter()]
51+
[string[]]$device_id,
52+
#The optional user_id/s for the events
53+
[Parameter()]
54+
[string[]]$user_id,
55+
#Switch to write errors to file
56+
[Parameter()]
57+
[switch]$errorsToFile
58+
)
59+
60+
begin {
61+
$url = "https://$($region).verkada.com/events/v1/access"
62+
#parameter validation
63+
if ([string]::IsNullOrEmpty($org_id)) {throw "org_id is missing but is required!"}
64+
if ([string]::IsNullOrEmpty($x_verkada_auth_api)) {throw "x_verkada_auth_api is missing but is required!"}
65+
$myErrors = @()
66+
} #end begin
67+
68+
process {
69+
$body_params = @{}
70+
$query_params = @{}
71+
72+
if (!([string]::IsNullOrEmpty($start_time))){
73+
$start_time_epoch = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $start_time).TotalSeconds
74+
$query_params.start_time = $start_time_epoch
75+
}
76+
if (!([string]::IsNullOrEmpty($end_time))){
77+
$end_time_epoch = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $end_time).TotalSeconds
78+
$query_params.end_time = $end_time_epoch
79+
}
80+
if (!([string]::IsNullOrEmpty($event_type))){$query_params.event_type = $event_type -join ','}
81+
if (!([string]::IsNullOrEmpty($site_id))){$query_params.site_ide = $site_id -join ','}
82+
if (!([string]::IsNullOrEmpty($device_id))){$query_params.device_id = $device_id -join ','}
83+
if (!([string]::IsNullOrEmpty($user_id))){$query_params.user_id = $user_id -join ','}
84+
85+
try {
86+
$response = Invoke-VerkadaRestMethod $url $org_id $x_verkada_auth_api $query_params -body_params $body_params -method GET -pagination -page_size 200 -propertyName 'events'
87+
return $response
88+
}
89+
catch [Microsoft.PowerShell.Commands.HttpResponseException] {
90+
$err = $_.ErrorDetails | ConvertFrom-Json
91+
$errorMes = $_ | Convertto-Json -WarningAction SilentlyContinue
92+
$err | Add-Member -NotePropertyName StatusCode -NotePropertyValue (($errorMes | ConvertFrom-Json -Depth 100 -WarningAction SilentlyContinue).Exception.Response.StatusCode) -Force
93+
$msg = "$($err.StatusCode) - $($err.message)"
94+
$msg += ": $(($query_params + $body_params) | ConvertTo-Json -Compress)"
95+
Write-Error $msg
96+
$myErrors += $msg
97+
$msg = $null
98+
}
99+
catch [VerkadaRestMethodException] {
100+
$msg = $_.ToString()
101+
$msg += ": $(($query_params + $body_params) | ConvertTo-Json -Compress)"
102+
Write-Error $msg
103+
$myErrors += $msg
104+
$msg = $null
105+
}
106+
} #end process
107+
108+
end {
109+
if ($errorsToFile.IsPresent){
110+
if (![string]::IsNullOrEmpty($myErrors)){
111+
Get-Date | Out-File ./errors.txt -Append
112+
$myErrors | Out-File ./errors.txt -Append
113+
}
114+
}
115+
} #end end
116+
} #end function

verkadaModule/verkadaModule.psd1

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Verkada SE Community
55
#
6-
# Generated on: 08/05/2025
6+
# Generated on: 09/30/2025
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
RootModule = 'verkadaModule.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.9.5'
15+
ModuleVersion = '0.9.6'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = 'Desktop', 'Core'
@@ -80,9 +80,10 @@ FunctionsToExport = 'Add-VerkadaAccessGroup', 'Add-VerkadaAccessSiteAdmin',
8080
'Enable-VerkadaAccessUserLicensePlate', 'Find-VerkadaCommandUser',
8181
'Find-VerkadaUserId', 'Get-Otp', 'Get-VerkadaAccessCredential',
8282
'Get-VerkadaAccessDoorConfigReport', 'Get-VerkadaAccessDoors',
83-
'Get-VerkadaAccessDoorSchedules', 'Get-VerkadaAccessGroup',
84-
'Get-VerkadaAccessLevels', 'Get-VerkadaAccessSite',
85-
'Get-VerkadaAccessUser', 'Get-VerkadaAccessUserProfilePicture',
83+
'Get-VerkadaAccessDoorSchedules', 'Get-VerkadaAccessEvents',
84+
'Get-VerkadaAccessGroup', 'Get-VerkadaAccessLevels',
85+
'Get-VerkadaAccessSite', 'Get-VerkadaAccessUser',
86+
'Get-VerkadaAccessUserProfilePicture',
8687
'Get-VerkadaAccessUserReport', 'Get-VerkadaAccessUserViaGraphql',
8788
'Get-VerkadaAlarmsDevices', 'Get-VerkadaAlarmsSiteConfig',
8889
'Get-VerkadaAlarmsSiteContacts', 'Get-VerkadaCameraConfig',
@@ -133,9 +134,9 @@ AliasesToExport = 'a-VrkdaAcGrp', 'Add-VrkdaAcGrp', 'a-VrkdaAcUsrCrd',
133134
'Add-VrkdaWrkEmp', 'd-VrkdaAcUsrCrd', 'Disable-VrkdaAcUsrCrd',
134135
'd-VrkdaAcUsrLPR', 'Disable-VrkdaAcUsrLPR', 'e-VrkdaAcUsrCrd',
135136
'Enable-VrkdaAcUsrCrd', 'e-VrkdaAcUsrLPR', 'Enable-VrkdaAcUsrLPR',
136-
'otp', 'Get-VrkdaAcGrp', 'gt-VrkdaAcGrp', 'Get-VrkdaAcUsr',
137-
'gt-VrkdaAcUsr', 'ep-VrkdaAcUsrPrflPic',
138-
'Export-VerkadaAccessUserProfilePicture',
137+
'otp', 'Get-VrkdaAcEvnts', 'gt-VrkdaAcEvnts', 'Get-VrkdaAcGrp',
138+
'gt-VrkdaAcGrp', 'Get-VrkdaAcUsr', 'gt-VrkdaAcUsr',
139+
'ep-VrkdaAcUsrPrflPic', 'Export-VerkadaAccessUserProfilePicture',
139140
'Export-VrkdaAcUsrPrflPic', 'g-VrkdaAcUsrPrflPic',
140141
'Get-VrkdaAcUsrPrflPic', 'g-VrkdAlrmDevs', 'Get-VrkdAlrmDevs',
141142
'Get-VerkadaCameraSite', 'Get-VrkdaCmdUsr', 'gt-VrkdaCmdUsr',

0 commit comments

Comments
 (0)