forked from gildas/posh-ic
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Remove-ICUser.ps1
38 lines (33 loc) · 979 Bytes
/
Remove-ICUser.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
<#
# AUTHOR : Pierrick Lozach, extended by Paul McGurn
#>
function Remove-ICUser() {
<#
.SYNOPSIS
Removes a user
.DESCRIPTION
Removes a user
.PARAMETER ICSession
The Interaction Center Session
.PARAMETER ICUser
The Interaction Center User
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)] [Alias("Session", "Id")] [PSObject] $ICSession,
[Parameter(Mandatory = $true)] [Alias("User")] [string] $ICUser
)
# User exists?
$userExists = Get-ICUser $ICSession -ICUser "${ICUser}"
if ([string]::IsNullOrEmpty($userExists)) {
# User does not exist
Write-Host "User ${ICUser} does not exist, no action taken"
return
}
$headers = @{
"Accept-Language" = $ICSession.language;
"ININ-ICWS-CSRF-Token" = $ICSession.token;
}
$response = Invoke-RestMethod -Uri "$($ICsession.baseURL)/$($ICSession.id)/configuration/users/$ICUser" -Method Delete -Headers $headers -WebSession $ICSession.webSession
return $response
}