-
Notifications
You must be signed in to change notification settings - Fork 0
/
departments.ps1
38 lines (32 loc) · 1.03 KB
/
departments.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
#######################################
# HelloID-Conn-Prov-Source-ilucca-Departments
#
# Version: 1.0.0
#######################################
# Initialize default value's
$config = $Configuration | ConvertFrom-Json
$secret = $config.secret
$customerUrl = $config.customerUrl
# Set debug logging
#region functions
#endregion
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
try{
$DepartmentsUri = "$customerUrl/api/v3/departments"
$headers = @{
'Authorization' = "Lucca application=$secret"
}
$result = Invoke-RestMethod -Uri $DepartmentsUri -Method GET -Headers $headers
$departments = $result.data.items
}catch{
throw "Error getting Ilucca departments $($_.Exception.Message)"
}
foreach ($d in $departments){
$department = [PSCustomObject]@{
ExternalId = $d.id
DisplayName = $d.name
Name = $d.name
}
Write-Output $department | ConvertTo-Json
}
Write-Information "Departments successfully imported";