-
Notifications
You must be signed in to change notification settings - Fork 5.4k
/
Copy pathGet-CippApiClient.ps1
43 lines (40 loc) · 1.21 KB
/
Get-CippApiClient.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
function Get-CippApiClient {
<#
.SYNOPSIS
Get the API client details
.DESCRIPTION
This function retrieves the API client details
.PARAMETER AppId
The AppId of the API client
.EXAMPLE
Get-CippApiClient -AppId 'cipp-api'
#>
[CmdletBinding()]
param (
$AppId
)
$Table = Get-CIPPTable -TableName 'ApiClients'
if ($AppId) {
$Table.Filter = "RowKey eq '$AppId'"
}
$Apps = Get-CIPPAzDataTableEntity @Table | Where-Object { ![string]::IsNullOrEmpty($_.RowKey) }
$Apps = foreach ($Client in $Apps) {
$Client = $Client | Select-Object -Property @{Name = 'ClientId'; Expression = { $_.RowKey } }, AppName, Role, IPRange, Enabled
if (!$Client.Role) {
$Client.Role = $null
}
if ($Client.IPRange) {
try {
$IPRange = @($Client.IPRange | ConvertFrom-Json -ErrorAction Stop)
if (($IPRange | Measure-Object).Count -eq 0) { @('Any') }
$Client.IPRange = $IPRange
} catch {
$Client.IPRange = @('Any')
}
} else {
$Client.IPRange = @('Any')
}
$Client
}
return $Apps
}