forked from gildas/posh-ic
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGet-ICUserByNtUserId.ps1
40 lines (31 loc) · 1.12 KB
/
Get-ICUserByNtUserId.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
<#
# AUTHOR : Paul McGurn, based on Pierrick Lozach's original work
#>
function Get-ICUserByNtUserId() {
# Documentation
<#
.SYNOPSIS
Gets an IC User by lookup of their NT user ID
.DESCRIPTION
Gets an IC User by lookup of their NT user ID
.PARAMETER ICSession
The Interaction Center Session
.PARAMETER NtUserId
The NT User ID for the user, ex. MyDomain\jsmith
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)] [Alias("Session", "Id")] $ICSession,
[Parameter(Mandatory = $true)] [Alias("NtUserId", "User")] [String] $ICNtUserId
)
$headers = @{
"Accept-Language" = $ICSession.language;
"ININ-ICWS-CSRF-Token" = $ICSession.token;
}
$requesturi = [String] $ICsession.baseURL + '/' + $ICSession.id + '/configuration/users?where='
$whereclause = 'ntDomainUser eq ' + [System.Web.HttpUtility]::UrlEncode($ICNtUserId)
$encodeduri = $requesturi + $whereclause
Write-Verbose "URI: ${encodeduri}"
$response = Invoke-RestMethod -Uri $encodeduri -Method Get -Headers $headers -WebSession $ICSession.webSession -ErrorAction Stop
return [PSCustomObject]$response.items.configurationid
}