Hello,
I'm trying to get VPN connect/disconnect events using Powershell to access the API. I can access all events, but I am having trouble filtering the events based on includedEventTypes.
Pretty simple code:
### start code ###
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$headers = @{
'Content-Type' = 'application/json'
"X-Cisco-Meraki-API-Key" = $APIKey
}
$Body = @{
"productType" = "appliance"
#"perPage" = "1000"
}
$Events = @()
$MerakiEvents = Invoke-RestMethod -Method Get -Uri $NetworkC10uri -Headers $headers -Body $Body
foreach ($event in $MerakiEvents.events)
{
$EventInfo = New-Object System.Object
$EventInfo | Add-Member -type NoteProperty -name occurredAt -Value $Event.occurredAt
$EventInfo | Add-Member -type NoteProperty -name Type -Value $Event.type
$EventInfo | Add-Member -type NoteProperty -name clientId -Value $Event.clientId
#$EventInfo | Add-Member -type NoteProperty -name Mac -Value $Event.mac
$Events += $EventInfo
}
$Events
### end code ###
The code above works great, but I can't figure out how to send a "collection" in the $body for includedEventTypes.
I want to filter by 'client_vpn_connect','client_vpn_disconnect'.
I have tried tons of formats, and can't find anything that works.
None of these examples work:
$Body = @{
"productType" = "appliance"
#"perPage" = "1000"
#"includedEventTypes" = @('client_vpn_connect', 'client_vpn_disconnect')
#"includedEventTypes" = 'client_vpn_connect','client_vpn_disconnect'
#includedEventTypes[] = 'client_vpn_connect','client_vpn_disconnect'
#'includedEventTypes[0]' = 'client_vpn_connect'
#"includedEventTypes" = $EventFilter
}
Any help would be greatly appreciated. Thanks.