-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathGet-SfbClientEvent.ps1
More file actions
52 lines (40 loc) · 1.65 KB
/
Get-SfbClientEvent.ps1
File metadata and controls
52 lines (40 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function Get-SfBClientEvent {
<#
.Synopsis
Helper function to get Skype for Business UCWA Events
.Description
This function queries the Skype for Business UCWA for new events. The timeout is passed to get an empty result with just a next link when there is no information from Skype for Business.
In the Skype for Business Client module, this function runs in a seperate runspace in the background to query incoming events.
#>
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Low')]
param (
# The timeout before the UCWA API sends an empty event, the minimum value is 180 seconds
[Parameter()]
[ValidateRange(180,1800)]
[int]$TimeOut,
# Skype for Business Client module context
[Parameter()]
[object]$Context = $SkypeForBusinessClientModuleContext
)
$rest = @{
ContentType = 'application/json'
Headers = $Context.authHeader
}
# Return the results from the event and store the next event in the context.
$eventUri = '{0}{1}' -f $Context.rootUri, $Context.events['next']
$null = $eventUri -match '(?<eventId>[0-9]*$)'
[int]$eventId = $matches.eventId
If($TimeOut) {
$eventUri = '{0}{1}' -f $eventUri, "&timeout=$TimeOut"
}
Try {
$event = Invoke-RestMethod -Method Get -Uri $eventUri @rest -ErrorAction stop
$Context.events['next'] = $event._links.next.href
# Store this event in the global context
$Context.events[$eventId] = $event
Write-Output $event
}
Catch {
Write-Error $_
}
}