Skip to content

Commit 573e14b

Browse files
committed
add skiplog parameter to test capabilities
1 parent 2e79bd7 commit 573e14b

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

Modules/CIPPCore/Public/Functions/Test-CIPPStandardLicense.ps1

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ function Test-CIPPStandardLicense {
2727
[string]$TenantFilter,
2828

2929
[Parameter(Mandatory = $true)]
30-
[string[]]$RequiredCapabilities
30+
[string[]]$RequiredCapabilities,
31+
32+
[Parameter(Mandatory = $false)]
33+
[switch]$SkipLog
3134
)
3235

3336
try {
@@ -41,16 +44,20 @@ function Test-CIPPStandardLicense {
4144
}
4245

4346
if ($Capabilities.Count -le 0) {
44-
Write-LogMessage -API 'Standards' -tenant $TenantFilter -message "Tenant does not have the required capability to run standard $StandardName`: The tenant needs one of the following service plans: $($RequiredCapabilities -join ',')" -sev Error
45-
Set-CIPPStandardsCompareField -FieldName "standards.$StandardName" -FieldValue "License Missing: This tenant is not licensed for the following capabilities: $($RequiredCapabilities -join ',')" -Tenant $TenantFilter
46-
Write-Host "Tenant does not have the required capability to run standard $StandardName - $($RequiredCapabilities -join ','). Exiting"
47+
if (!$SkipLog.IsPresent) {
48+
Write-LogMessage -API 'Standards' -tenant $TenantFilter -message "Tenant does not have the required capability to run standard $StandardName`: The tenant needs one of the following service plans: $($RequiredCapabilities -join ',')" -sev Error
49+
Set-CIPPStandardsCompareField -FieldName "standards.$StandardName" -FieldValue "License Missing: This tenant is not licensed for the following capabilities: $($RequiredCapabilities -join ',')" -Tenant $TenantFilter
50+
Write-Host "Tenant does not have the required capability to run standard $StandardName - $($RequiredCapabilities -join ','). Exiting"
51+
}
4752
return $false
4853
}
4954
Write-Host "Tenant has the required capabilities for standard $StandardName"
5055
return $true
5156
} catch {
52-
Write-LogMessage -API 'Standards' -tenant $TenantFilter -message "Error checking license capabilities for standard $StandardName`: $($_.Exception.Message)" -sev Error
53-
Set-CIPPStandardsCompareField -FieldName "standards.$StandardName" -FieldValue "License Missing: Error checking license capabilities - $($_.Exception.Message)" -Tenant $TenantFilter
57+
if (!$SkipLog.IsPresent) {
58+
Write-LogMessage -API 'Standards' -tenant $TenantFilter -message "Error checking license capabilities for standard $StandardName`: $($_.Exception.Message)" -sev Error
59+
Set-CIPPStandardsCompareField -FieldName "standards.$StandardName" -FieldValue "License Missing: Error checking license capabilities - $($_.Exception.Message)" -Tenant $TenantFilter
60+
}
5461
return $false
5562
}
5663
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function Invoke-CIPPStandardConditionalAccessTemplate {
3232
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'ConditionalAccess'
3333
$Table = Get-CippTable -tablename 'templates'
3434
$TestResult = Test-CIPPStandardLicense -StandardName 'ConditionalAccessTemplate_general' -TenantFilter $Tenant -RequiredCapabilities @('AAD_PREMIUM', 'AAD_PREMIUM_P2')
35-
$TestP2 = Test-CIPPStandardLicense -StandardName 'ConditionalAccessTemplate_p2' -TenantFilter $Tenant -RequiredCapabilities @('AAD_PREMIUM_P2')
35+
$TestP2 = Test-CIPPStandardLicense -StandardName 'ConditionalAccessTemplate_p2' -TenantFilter $Tenant -RequiredCapabilities @('AAD_PREMIUM_P2') -SkipLog
3636
if ($TestResult -eq $false) {
3737
#writing to each item that the license is not present.
3838
$settings.TemplateList | ForEach-Object {
@@ -59,6 +59,7 @@ function Invoke-CIPPStandardConditionalAccessTemplate {
5959
if ($Policy.conditions.userRiskLevels.count -gt 0 -or $Policy.conditions.signInRiskLevels.count -gt 0) {
6060
if (!$TestP2) {
6161
Write-Information "Skipping policy $($Policy.displayName) as it requires AAD Premium P2 license."
62+
Set-CIPPStandardsCompareField -FieldName "standards.ConditionalAccessTemplate.$($Setting.value)" -FieldValue "Policy $($Policy.displayName) requires AAD Premium P2 license." -Tenant $Tenant
6263
continue
6364
}
6465
}

0 commit comments

Comments
 (0)