-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Expand file tree
/
Copy pathSet-CIPPStandardsCompareField.ps1
More file actions
40 lines (37 loc) · 1.65 KB
/
Set-CIPPStandardsCompareField.ps1
File metadata and controls
40 lines (37 loc) · 1.65 KB
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
function Set-CIPPStandardsCompareField {
[CmdletBinding(SupportsShouldProcess = $true)]
param (
$FieldName,
$FieldValue,
$TenantFilter
)
$Table = Get-CippTable -tablename 'CippStandardsReports'
$TenantName = Get-Tenants -TenantFilter $TenantFilter
if ($FieldValue -is [System.Boolean]) {
$FieldValue = [bool]$FieldValue
} elseif ($FieldValue -is [string]) {
$FieldValue = [string]$FieldValue
} else {
$FieldValue = ConvertTo-Json -Compress -InputObject @($FieldValue) -Depth 10 | Out-String
$FieldValue = [string]$FieldValue
}
$Existing = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq '$($TenantName.defaultDomainName)' and RowKey eq '$($FieldName)'"
if ($PSCmdlet.ShouldProcess('CIPP Standards Compare', "Set field '$FieldName' to '$FieldValue' for tenant '$($TenantName.defaultDomainName)'")) {
try {
if ($Existing) {
$Existing.Value = $FieldValue
Add-CIPPAzDataTableEntity @Table -Entity $Existing -Force
} else {
$Result = [PSCustomObject]@{
PartitionKey = [string]$TenantName.defaultDomainName
RowKey = [string]$FieldName
Value = $FieldValue
}
Add-CIPPAzDataTableEntity @Table -Entity $Result -Force
}
Write-Information "Adding $FieldName to StandardCompare for $Tenant. content is $FieldValue"
} catch {
Write-Warning "Failed to add $FieldName to StandardCompare for $Tenant. content is $FieldValue - $($_.Exception.Message)"
}
}
}