forked from gildas/posh-ic
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Get-ICUser.ps1
48 lines (42 loc) · 1.24 KB
/
Get-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
38
39
40
41
42
43
44
45
46
47
<#
# AUTHOR : Pierrick Lozach, Extended by Paul McGurn
#>
function Get-ICUser() {
<#
.SYNOPSIS
Gets a user
.DESCRIPTION
Gets a user
.PARAMETER ICSession
The Interaction Center Session
.PARAMETER ICUser
The Interaction Center User
.PARAMETER Fields
The user fields to include with the returned user object, ex. extension, ntDomainUser, etc. Comma-separated list of case-sensitive fields.
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)] [Alias("Session", "Id")] $ICSession,
[Parameter(Mandatory = $true)] [Alias("User")] [string] $ICUser,
[Parameter(Mandatory = $false)] [string]$fields
)
if (! $PSBoundParameters.ContainsKey('ICUser')) {
$ICUser = $ICSession.user
}
$headers = @{
"Accept-Language" = $ICSession.language;
"ININ-ICWS-CSRF-Token" = $ICSession.token;
}
$response = '';
$requesturi = "$($ICsession.baseURL)/$($ICSession.id)/configuration/users/${ICUser}?select=*"
try {
$response = Invoke-RestMethod -Uri $requesturi -Method Get -Headers $headers -WebSession $ICSession.webSession
}
catch {
# If user not found, ignore the exception
if (-not ($_.Exception.message -match '404')) {
Write-Verbose "User not found, exiting silently"
}
}
return $response
}