From 51786810ba1260c954c298c23d8f1f9ee9c2a683 Mon Sep 17 00:00:00 2001 From: John Duprey Date: Mon, 4 Nov 2024 12:04:50 -0500 Subject: [PATCH] bugfix --- .../CIPPCore/Public/Standards/Get-CIPPStandards.ps1 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Modules/CIPPCore/Public/Standards/Get-CIPPStandards.ps1 b/Modules/CIPPCore/Public/Standards/Get-CIPPStandards.ps1 index b3ec11c8c96b..4aea97d2fc9e 100644 --- a/Modules/CIPPCore/Public/Standards/Get-CIPPStandards.ps1 +++ b/Modules/CIPPCore/Public/Standards/Get-CIPPStandards.ps1 @@ -2,7 +2,8 @@ function Get-CIPPStandards { param( [Parameter(Mandatory = $false)] [string]$TenantFilter = 'allTenants', - [switch]$ListAllTenants + [switch]$ListAllTenants, + [switch]$SkipGetTenants ) #Write-Host "Getting standards for tenant - $($tenantFilter)" @@ -12,7 +13,12 @@ function Get-CIPPStandards { $StandardsAllTenants = $Standards | Where-Object { $_.Tenant -eq 'AllTenants' } # Get tenant list based on filter - $Tenants = Get-Tenants + if ($SkipGetTenants.IsPresent) { + # Debugging flag to skip Get-Tenants + $Tenants = $Standards.Tenant | Sort-Object -Unique | ForEach-Object { [pscustomobject]@{ defaultDomainName = $_ } } + } else { + $Tenants = Get-Tenants + } if ($TenantFilter -ne 'allTenants') { $Tenants = $Tenants | Where-Object { $_.defaultDomainName -eq $TenantFilter -or $_.customerId -eq $TenantFilter } } @@ -63,8 +69,7 @@ function Get-CIPPStandards { $ComputedStandards[$StandardName] = $CurrentStandard } else { foreach ($Setting in $CurrentStandard.PSObject.Properties.Name) { - # Write-Host "$Setting - Current: $($CurrentStandard.$Setting) | Computed: $($ComputedStandards[$StandardName].$($Setting))" - if ($CurrentStandard.$Setting -ne $false -and ($CurrentStandard.$Setting -ne $ComputedStandards[$StandardName].$($Setting) -and ![string]::IsNullOrWhiteSpace($CurrentStandard.$Setting -or (Compare-Object $CurrentStandard.$Setting $ComputedStandards[$StandardName].$($Setting))))) { + if ($CurrentStandard.$Setting -ne $false -and ($CurrentStandard.$Setting -ne $ComputedStandards[$StandardName].$($Setting) -and ![string]::IsNullOrWhiteSpace($CurrentStandard.$Setting) -or ($null -ne $CurrentStandard.$Setting -and $null -ne $ComputedStandards[$StandardName].$($Setting) -and (Compare-Object $CurrentStandard.$Setting $ComputedStandards[$StandardName].$($Setting))))) { #Write-Host "Overriding $Setting for $StandardName at tenant level" if ($ComputedStandards[$StandardName].PSObject.Properties.Name -contains $Setting) { $ComputedStandards[$StandardName].$($Setting) = $CurrentStandard.$Setting