Skip to content

Commit bfe9a6f

Browse files
committed
Add null checks for tenant and standard keys
Added explicit checks to ensure $Tenant and $StandardKey are not null or empty before accessing or modifying related data structures. This improves robustness and prevents potential runtime errors.
1 parent 1b1e1c7 commit bfe9a6f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function Get-CIPPTenantAlignment {
8686
}
8787
}
8888

89-
if (-not $tenantData.ContainsKey($Tenant)) {
89+
if ($Tenant -and -not $tenantData.ContainsKey($Tenant)) {
9090
$tenantData[$Tenant] = @{}
9191
}
9292
$tenantData[$Tenant][$FieldName] = @{
@@ -245,7 +245,8 @@ function Get-CIPPTenantAlignment {
245245
# Use HashSet for Contains
246246
$IsReportingDisabled = $ReportingDisabledSet.Contains($StandardKey)
247247
# Use cached tenant data
248-
$HasStandard = $CurrentTenantStandards.ContainsKey($StandardKey)
248+
249+
$HasStandard = $StandardKey -and $CurrentTenantStandards.ContainsKey($StandardKey)
249250

250251
if ($HasStandard) {
251252
$StandardObject = $CurrentTenantStandards[$StandardKey]

0 commit comments

Comments
 (0)