Skip to content

Commit 2e6997f

Browse files
authored
Merge pull request #1488 from KelvinTegelaar/dev
Dev to hotfix
2 parents 131fe26 + 897c0e7 commit 2e6997f

File tree

7 files changed

+78
-46
lines changed

7 files changed

+78
-46
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-GetCippAlerts.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function Invoke-GetCippAlerts {
1919
$PartitionKey = Get-Date -UFormat '%Y%m%d'
2020
$Filter = "PartitionKey eq '{0}'" -f $PartitionKey
2121
$Rows = Get-CIPPAzDataTableEntity @Table -Filter $Filter | Sort-Object TableTimestamp -Descending | Select-Object -First 10
22-
$Role = ([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Request.Headers.'x-ms-client-principal')) | ConvertFrom-Json).userRoles
22+
$Role = Get-CippAccessRole -Request $Request
2323

2424
$CIPPVersion = $Request.Query.localversion
2525
$Version = Assert-CippVersion -CIPPVersion $CIPPVersion

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Standards/Invoke-ListStandardsCompare.ps1

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ function Invoke-ListStandardsCompare {
1414
$Table = Get-CIPPTable -TableName 'CippStandardsReports'
1515
$TenantFilter = $Request.Query.tenantFilter
1616
if ($TenantFilter) {
17-
$Table.Filter = "RowKey eq '{0}'" -f $TenantFilter
17+
$Table.Filter = "PartitionKey eq '{0}'" -f $TenantFilter
1818
}
1919

20-
$Results = Get-CIPPAzDataTableEntity @Table
20+
$Standards = Get-CIPPAzDataTableEntity @Table
2121

2222
#in the results we have objects starting with "standards." All these have to be converted from JSON. Do not do this is its a boolean
23-
$Results | ForEach-Object {
23+
<#$Results | ForEach-Object {
2424
$Object = $_
2525
$Object.PSObject.Properties | ForEach-Object {
2626
if ($_.Name -like 'standards_*') {
@@ -40,8 +40,43 @@ function Invoke-ListStandardsCompare {
4040
$object.PSObject.Properties.Remove($_.Name)
4141
}
4242
}
43+
}#>
44+
45+
$TenantStandards = @{}
46+
$Results = [System.Collections.Generic.List[object]]::new()
47+
48+
foreach ($Standard in $Standards) {
49+
# each standard is on their own row now, the field name is the RowKey and the value is in the Value field
50+
$FieldName = $Standard.RowKey
51+
$FieldValue = $Standard.Value
52+
$Tenant = $Standard.PartitionKey
53+
if ($FieldValue -is [System.Boolean]) {
54+
$FieldValue = [bool]$FieldValue
55+
} elseif ($FieldValue -like '*{*') {
56+
$FieldValue = ConvertFrom-Json -InputObject $FieldValue -ErrorAction SilentlyContinue
57+
} else {
58+
$FieldValue = [string]$FieldValue
59+
}
60+
61+
if (-not $TenantStandards.ContainsKey($Tenant)) {
62+
$TenantStandards[$Tenant] = @{}
63+
}
64+
$TenantStandards[$Tenant][$FieldName] = @{
65+
Value = $FieldValue
66+
LastRefresh = $Standard.TimeStamp.ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
67+
}
4368
}
4469

70+
foreach ($Tenant in $TenantStandards.Keys) {
71+
$TenantStandard = [PSCustomObject]@{
72+
tenantFilter = $Tenant
73+
}
74+
foreach ($Field in $TenantStandards[$Tenant].Keys) {
75+
$Value = $TenantStandards[$Tenant][$Field]
76+
$TenantStandard | Add-Member -MemberType NoteProperty -Name $Field -Value $Value -Force
77+
}
78+
$Results.Add($TenantStandard)
79+
}
4580

4681
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
4782
StatusCode = [HttpStatusCode]::OK

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Standards/Invoke-listStandardTemplates.ps1

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,20 @@ function Invoke-listStandardTemplates {
2828
Write-Host "$($RowKey) standard could not be loaded: $($_.Exception.Message)"
2929
return
3030
}
31-
$Data | Add-Member -NotePropertyName 'GUID' -NotePropertyValue $_.GUID -Force
32-
33-
if (!$Data.excludedTenants) {
34-
$Data | Add-Member -NotePropertyName 'excludedTenants' -NotePropertyValue @() -Force
35-
}
36-
37-
if ($Data.excludedTenants -and $Data.excludedTenants -ne 'excludedTenants') {
38-
$Data.excludedTenants = @($Data.excludedTenants)
39-
} else {
40-
$Data.excludedTenants = @()
31+
if ($Data) {
32+
$Data | Add-Member -NotePropertyName 'GUID' -NotePropertyValue $_.GUID -Force
33+
34+
if (!$Data.excludedTenants) {
35+
$Data | Add-Member -NotePropertyName 'excludedTenants' -NotePropertyValue @() -Force
36+
} else {
37+
if ($Data.excludedTenants -and $Data.excludedTenants -ne 'excludedTenants') {
38+
$Data.excludedTenants = @($Data.excludedTenants)
39+
} else {
40+
$Data.excludedTenants = @()
41+
}
42+
}
43+
$Data
4144
}
42-
$Data
4345
} | Sort-Object -Property templateName
4446

4547
if ($ID) { $Templates = $Templates | Where-Object GUID -EQ $ID }

Modules/CIPPCore/Public/Entrypoints/Orchestrator Functions/Start-AuditLogSearchCreation.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ function Start-AuditLogSearchCreation {
99
$ConfigTable = Get-CippTable -TableName 'WebhookRules'
1010
$ConfigEntries = Get-CIPPAzDataTableEntity @ConfigTable -Filter "PartitionKey eq 'Webhookv2'" | ForEach-Object {
1111
$ConfigEntry = $_
12-
$ConfigEntry.excludedTenants = $ConfigEntry.excludedTenants | ConvertFrom-Json
12+
if (!$ConfigEntry.excludedTenants) {
13+
$ConfigEntry | Add-Member -MemberType NoteProperty -Name 'excludedTenants' -Value @() -Force
14+
} else {
15+
$ConfigEntry.excludedTenants = $ConfigEntry.excludedTenants | ConvertFrom-Json
16+
}
1317
$ConfigEntry.Tenants = $ConfigEntry.Tenants | ConvertFrom-Json
1418
$ConfigEntry
1519
}
Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,40 @@
11
function Set-CIPPStandardsCompareField {
2+
[CmdletBinding(SupportsShouldProcess = $true)]
23
param (
34
$FieldName,
45
$FieldValue,
56
$TenantFilter
67
)
78
$Table = Get-CippTable -tablename 'CippStandardsReports'
8-
$TenantName = Get-Tenants | Where-Object -Property defaultDomainName -EQ $Tenant
9-
10-
# Sanitize invalid c#/xml characters for Azure Tables
11-
$FieldName = $FieldName.replace('standards.', 'standards_')
12-
$FieldName = $FieldName.replace('IntuneTemplate.', 'IntuneTemplate_')
13-
$FieldName = $FieldName -replace '-', '__'
9+
$TenantName = Get-Tenants -TenantFilter $TenantFilter
1410

1511
if ($FieldValue -is [System.Boolean]) {
16-
$fieldValue = [bool]$FieldValue
12+
$FieldValue = [bool]$FieldValue
1713
} elseif ($FieldValue -is [string]) {
1814
$FieldValue = [string]$FieldValue
1915
} else {
2016
$FieldValue = ConvertTo-Json -Compress -InputObject @($FieldValue) -Depth 10 | Out-String
2117
$FieldValue = [string]$FieldValue
2218
}
2319

24-
$Existing = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq 'StandardReport' and RowKey eq '$($TenantName.defaultDomainName)'"
25-
try {
26-
if ($Existing) {
27-
$Existing = $Existing | Select-Object * -ExcludeProperty ETag, TimeStamp | ConvertTo-Json -Depth 10 -Compress | ConvertFrom-Json -AsHashtable
28-
$Existing[$FieldName] = $FieldValue
29-
$Existing['LastRefresh'] = [string]$(Get-Date (Get-Date).ToUniversalTime() -UFormat '+%Y-%m-%dT%H:%M:%S.000Z')
30-
$Existing = [PSCustomObject]$Existing
20+
$Existing = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq '$($TenantName.defaultDomainName)' and RowKey eq '$($FieldName)'"
3121

32-
Add-CIPPAzDataTableEntity @Table -Entity $Existing -Force
33-
} else {
34-
$Result = @{
35-
tenantFilter = "$($TenantName.defaultDomainName)"
36-
GUID = "$($TenantName.customerId)"
37-
RowKey = "$($TenantName.defaultDomainName)"
38-
PartitionKey = 'StandardReport'
39-
LastRefresh = [string]$(Get-Date (Get-Date).ToUniversalTime() -UFormat '+%Y-%m-%dT%H:%M:%S.000Z')
22+
if ($PSCmdlet.ShouldProcess('CIPP Standards Compare', "Set field '$FieldName' to '$FieldValue' for tenant '$($TenantName.defaultDomainName)'")) {
23+
try {
24+
if ($Existing) {
25+
$Existing.Value = $FieldValue
26+
Add-CIPPAzDataTableEntity @Table -Entity $Existing -Force
27+
} else {
28+
$Result = [PSCustomObject]@{
29+
PartitionKey = [string]$TenantName.defaultDomainName
30+
RowKey = [string]$FieldName
31+
Value = $FieldValue
32+
}
33+
Add-CIPPAzDataTableEntity @Table -Entity $Result -Force
4034
}
41-
$Result[$FieldName] = $FieldValue
42-
Add-CIPPAzDataTableEntity @Table -Entity $Result -Force
43-
35+
Write-Information "Adding $FieldName to StandardCompare for $Tenant. content is $FieldValue"
36+
} catch {
37+
Write-Warning "Failed to add $FieldName to StandardCompare for $Tenant. content is $FieldValue - $($_.Exception.Message)"
4438
}
45-
Write-Information "Adding $FieldName to StandardCompare for $Tenant. content is $FieldValue"
46-
} catch {
47-
Write-Warning "Failed to add $FieldName to StandardCompare for $Tenant. content is $FieldValue - $($_.Exception.Message)"
4839
}
4940
}

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardGlobalQuarantineNotifications.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function Invoke-CIPPStandardGlobalQuarantineNotifications {
6464
} else {
6565
try {
6666
if ($CurrentState.Name -eq 'DefaultGlobalPolicy') {
67-
$null = New-ExoRequest -tenantid $Tenant -cmdlet 'New-QuarantinePolicy' -cmdParams @{ Name = 'DefaultGlobalTag'; QuarantinePolicyType = 'GlobalQuarantinePolicy'; EndUserSpamNotificationFrequency = [string]$WantedState.TotalHours }
67+
$null = New-ExoRequest -tenantid $Tenant -cmdlet 'New-QuarantinePolicy' -cmdParams @{ Name = 'DefaultGlobalTag'; QuarantinePolicyType = 'GlobalQuarantinePolicy'; EndUserSpamNotificationFrequency = [string]$WantedState }
6868
} else {
6969
$null = New-ExoRequest -tenantid $Tenant -cmdlet 'Set-QuarantinePolicy' -cmdParams @{Identity = $CurrentState.Identity; EndUserSpamNotificationFrequency = [string]$WantedState }
7070
}

version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.0.2
1+
8.0.3

0 commit comments

Comments
 (0)