Skip to content

Commit 361a68f

Browse files
fixes
1 parent f580978 commit 361a68f

File tree

4 files changed

+56
-21
lines changed

4 files changed

+56
-21
lines changed

Modules/CIPPCore/Public/Alerts/Get-CIPPAlertLowTenantAlignment.ps1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function Get-CIPPAlertLowTenantAlignment {
1414
Get-CIPPAlertLowTenantAlignment -TenantFilter "contoso.onmicrosoft.com" -InputValue 75
1515
#>
1616
[CmdletBinding()]
17-
Param (
17+
param (
1818
[Parameter(Mandatory)]
1919
$TenantFilter,
2020
[Alias('input')]
@@ -31,7 +31,16 @@ function Get-CIPPAlertLowTenantAlignment {
3131
return
3232
}
3333

34-
$LowAlignmentAlerts = $AlignmentData | Where-Object { $_.AlignmentScore -lt $InputValue }
34+
$LowAlignmentAlerts = $AlignmentData | Where-Object { $_.AlignmentScore -lt $InputValue } | ForEach-Object {
35+
[PSCustomObject]@{
36+
TenantFilter = $_.TenantFilter
37+
StandardName = $_.StandardName
38+
StandardId = $_.StandardId
39+
AlignmentScore = $_.AlignmentScore
40+
LicenseMissingPercentage = $_.LicenseMissingPercentage
41+
LatestDataCollection = $_.LatestDataCollection
42+
}
43+
}
3544

3645
if ($LowAlignmentAlerts.Count -gt 0) {
3746
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $LowAlignmentAlerts

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ function Invoke-ListTenantAlignment {
2020
# Transform the data to match the expected API response format
2121
$Results = $AlignmentData | ForEach-Object {
2222
[PSCustomObject]@{
23-
tenantFilter = $_.TenantFilter
24-
standardName = $_.StandardName
25-
standardId = $_.StandardId
26-
alignmentScore = $_.AlignmentScore
27-
latestDataCollection = $_.LatestDataCollection
23+
tenantFilter = $_.TenantFilter
24+
standardName = $_.StandardName
25+
standardId = $_.StandardId
26+
alignmentScore = $_.AlignmentScore
27+
LicenseMissingPercentage = $_.LicenseMissingPercentage
28+
latestDataCollection = $_.LatestDataCollection
2829
}
2930
}
3031

Modules/CIPPCore/Public/Functions/Get-CIPPTenantAlignment.ps1

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,14 @@ function Get-CIPPTenantAlignment {
179179
}
180180

181181
$IsCompliant = ($Value -eq $true)
182+
$IsLicenseMissing = ($Value -is [string] -and $Value -like "License Missing:*")
182183

183184
if ($IsReportingDisabled) {
184185
$ComplianceStatus = 'Reporting Disabled'
185186
} elseif ($IsCompliant) {
186187
$ComplianceStatus = 'Compliant'
188+
} elseif ($IsLicenseMissing) {
189+
$ComplianceStatus = 'License Missing'
187190
} else {
188191
$ComplianceStatus = 'Non-Compliant'
189192
}
@@ -214,6 +217,7 @@ function Get-CIPPTenantAlignment {
214217

215218
$CompliantStandards = ($ComparisonTable | Where-Object { $_.ComplianceStatus -eq 'Compliant' }).Count
216219
$NonCompliantStandards = ($ComparisonTable | Where-Object { $_.ComplianceStatus -eq 'Non-Compliant' }).Count
220+
$LicenseMissingStandards = ($ComparisonTable | Where-Object { $_.ComplianceStatus -eq 'License Missing' }).Count
217221
$ReportingDisabledStandardsCount = ($ComparisonTable | Where-Object { $_.ReportingDisabled }).Count
218222

219223
$AlignmentPercentage = if (($AllCount - $ReportingDisabledStandardsCount) -gt 0) {
@@ -222,17 +226,25 @@ function Get-CIPPTenantAlignment {
222226
0
223227
}
224228

229+
$LicenseMissingPercentage = if ($AllCount -gt 0) {
230+
[Math]::Round(($LicenseMissingStandards / $AllCount) * 100)
231+
} else {
232+
0
233+
}
234+
225235
$Result = [PSCustomObject]@{
226-
TenantFilter = $TenantName
227-
StandardName = $Template.templateName
228-
StandardId = $Template.GUID
229-
AlignmentScore = $AlignmentPercentage
230-
CompliantStandards = $CompliantStandards
231-
NonCompliantStandards = $NonCompliantStandards
232-
TotalStandards = $AllCount
236+
TenantFilter = $TenantName
237+
StandardName = $Template.templateName
238+
StandardId = $Template.GUID
239+
AlignmentScore = $AlignmentPercentage
240+
LicenseMissingPercentage = $LicenseMissingPercentage
241+
CompliantStandards = $CompliantStandards
242+
NonCompliantStandards = $NonCompliantStandards
243+
LicenseMissingStandards = $LicenseMissingStandards
244+
TotalStandards = $AllCount
233245
ReportingDisabledCount = $ReportingDisabledStandardsCount
234-
LatestDataCollection = if ($LatestDataCollection) { $LatestDataCollection } else { $null }
235-
ComparisonDetails = $ComparisonTable
246+
LatestDataCollection = if ($LatestDataCollection) { $LatestDataCollection } else { $null }
247+
ComparisonDetails = $ComparisonTable
236248
}
237249

238250
$Results.Add($Result)

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ function Invoke-CIPPStandardConditionalAccessTemplate {
3131
param($Tenant, $Settings)
3232
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'ConditionalAccess'
3333

34-
If ($Settings.remediate -eq $true) {
35-
34+
if ($Settings.remediate -eq $true) {
35+
$AllCAPolicies = New-GraphGetRequest -Uri 'https://graph.microsoft.com/beta/identity/conditionalAccess/policies?$top=999' -tenantid $Tenant
3636
foreach ($Setting in $Settings) {
3737
try {
38-
3938
$Table = Get-CippTable -tablename 'templates'
4039
$Filter = "PartitionKey eq 'CATemplate' and RowKey eq '$($Setting.TemplateList.value)'"
4140
$JSONObj = (Get-CippAzDataTableEntity @Table -Filter $Filter).JSON
@@ -45,7 +44,21 @@ function Invoke-CIPPStandardConditionalAccessTemplate {
4544
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to create or update conditional access rule $($JSONObj.displayName). Error: $ErrorMessage" -sev 'Error'
4645
}
4746
}
48-
49-
47+
}
48+
if ($Settings.report -eq $true) {
49+
$Policies = $Settings.TemplateList.JSON | ConvertFrom-Json -Depth 10
50+
#check if all groups.displayName are in the existingGroups, if not $fieldvalue should contain all missing groups, else it should be true.
51+
$MissingPolicies = foreach ($policy in $Policies) {
52+
$CheckExististing = $AllCAPolicies | Where-Object -Property displayName -EQ $policy.displayname
53+
if (!$CheckExististing) {
54+
$policy.displayname
55+
}
56+
}
57+
if ($MissingPolicies.Count -eq 0) {
58+
$fieldValue = $true
59+
} else {
60+
$fieldValue = $MissingPolicies -join ', '
61+
}
62+
Set-CIPPStandardsCompareField -FieldName 'standards.GroupTemplate' -FieldValue $fieldValue -Tenant $Tenant
5063
}
5164
}

0 commit comments

Comments
 (0)