Skip to content

Commit 4f00fd1

Browse files
committed
remove + objects in all tenants exxclusion
use generic list
1 parent 39dde3c commit 4f00fd1

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecOnboardTenantQueue.ps1

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Function Push-ExecOnboardTenantQueue {
1+
function Push-ExecOnboardTenantQueue {
22
<#
33
.FUNCTIONALITY
44
Entrypoint
@@ -354,22 +354,29 @@ Function Push-ExecOnboardTenantQueue {
354354
if ($OnboardingSteps.Step4.Status -eq 'succeeded') {
355355
if ($Item.StandardsExcludeAllTenants -eq $true) {
356356
$AddExclusionObj = [PSCustomObject]@{
357-
label = $Tenant.defaultDomainName
357+
label = '{0} ({1})' -f $Tenant.displayName, $Tenant.defaultDomainName
358358
value = $Tenant.defaultDomainName
359-
addedFields = @{}
359+
addedFields = @{
360+
customerId = $Tenant.customerId
361+
defaultDomainName = $Tenant.defaultDomainName
362+
}
360363
}
361364
$Table = Get-CippTable -tablename 'templates'
362365
$ExistingTemplates = Get-CippazDataTableEntity @Table -Filter "PartitionKey eq 'StandardsTemplateV2'" | Where-Object { $_.JSON -match 'AllTenants' }
363-
foreach ($AllTenantesTemplate in $ExistingTemplates) {
366+
foreach ($AllTenantsTemplate in $ExistingTemplates) {
364367
$object = $AllTenantesTemplate.JSON | ConvertFrom-Json
365-
$NewExcludedTenants = $object.excludedTenants + $AddExclusionObj
368+
$NewExcludedTenants = [system.collections.generic.list[object]]::new()
369+
foreach ($Tenant in $object.excludedTenants) {
370+
$NewExcludedTenants.Add($Tenant)
371+
}
372+
$NewExcludedTenants.Add($AddExclusionObj)
366373
$object.excludedTenants = $NewExcludedTenants
367374
$JSON = ConvertTo-Json -InputObject $object -Compress -Depth 10
368375
$Table.Force = $true
369376
Add-CIPPAzDataTableEntity @Table -Entity @{
370377
JSON = "$JSON"
371-
RowKey = $AllTenantesTemplate.RowKey
372-
GUID = $AllTenantesTemplate.GUID
378+
RowKey = $AllTenantsTemplate.RowKey
379+
GUID = $AllTenantsTemplate.GUID
373380
PartitionKey = 'StandardsTemplateV2'
374381
}
375382
}

0 commit comments

Comments
 (0)