-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathRemove-SfbClientContext.ps1
42 lines (32 loc) · 1.33 KB
/
Remove-SfbClientContext.ps1
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
function Remove-SfbClientContext {
<#
.Synopsis
Removes an Skype for Business Client Context created by New-SfbClientContext
.Description
This function deletes the Skype for Business UCWA application and disposes all runspaces started by functions in the SkypeForBusinessClient module.
.Example
Remove-SfbClientContext
Remove the context stored in $SkypeForBusinessClientModuleContext
#>
[CmdletBinding()]
param (
# The Skype for Business application context
[Parameter()]
[Object]$Context = $SkypeForBusinessClientModuleContext
)
$json = 'application/json'
$rest = @{
ContentType = $json
Headers = $Context.authHeader
}
$applicationContextUri = '{0}{1}' -f $context.rootUri,$context.application._links.self.href
Try {
$null = Invoke-RestMethod -Uri $applicationContextUri -Method Delete @rest -ErrorAction Stop
$null = $Context.backgroundProcesses.Runspace | ForEach-Object {$_.Stop()}
$null = $Context.backgroundProcesses.Runspace | ForEach-Object {$_.Dispose()}
$Global:SkypeForBusinessClientModuleContext = $null
}
Catch {
Write-Warning "Failed to remove SkypeForBusinessClient Context: $_"
}
}