Skip to content

Commit 891f833

Browse files
offboarding excludeAllTenants
1 parent 4661597 commit 891f833

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -353,26 +353,27 @@ Function Push-ExecOnboardTenantQueue {
353353

354354
if ($OnboardingSteps.Step4.Status -eq 'succeeded') {
355355
if ($Item.StandardsExcludeAllTenants -eq $true) {
356-
$Settings = @{
357-
'OverrideAllTenants' = @{
358-
'remediate' = $true
356+
$AddExclusionObj = [PSCustomObject]@{
357+
label = $Tenant.defaultDomainName
358+
value = $Tenant.defaultDomainName
359+
addedFields = @{}
360+
}
361+
$Table = Get-CippTable -tablename 'templates'
362+
$ExistingTemplates = Get-CippazDataTableEntity @Table -Filter "PartitionKey eq 'StandardsTemplateV2'" | Where-Object { $_.JSON -match 'AllTenants' }
363+
foreach ($AllTenantesTemplate in $ExistingTemplates) {
364+
$object = $AllTenantesTemplate.JSON | ConvertFrom-Json
365+
$NewExcludedTenants = $object.excludedTenants + $AddExclusionObj
366+
$object.excludedTenants = $NewExcludedTenants
367+
$JSON = ConvertTo-Json -InputObject $object -Compress -Depth 10
368+
$Table.Force = $true
369+
Add-CIPPAzDataTableEntity @Table -Entity @{
370+
JSON = "$JSON"
371+
RowKey = $AllTenantesTemplate.RowKey
372+
GUID = $AllTenantesTemplate.GUID
373+
PartitionKey = 'StandardsTemplateV2'
359374
}
360375
}
361-
$object = [PSCustomObject]@{
362-
Tenant = $Tenant.defaultDomainName
363-
AddedBy = 'Onboarding'
364-
AppliedAt = (Get-Date).ToString('s')
365-
Standards = $Settings
366-
v2 = $true
367-
} | ConvertTo-Json -Depth 10
368376

369-
$Table = Get-CippTable -tablename 'standards'
370-
$Table.Force = $true
371-
Add-CIPPAzDataTableEntity @Table -Entity @{
372-
JSON = "$object"
373-
RowKey = [string]$Tenant.defaultDomainName
374-
PartitionKey = 'standards'
375-
}
376377
$Logs.Add([PSCustomObject]@{ Date = (Get-Date).ToUniversalTime(); Log = 'Set All Tenant Standards Exclusion' })
377378
}
378379
$Logs.Add([PSCustomObject]@{ Date = (Get-Date).ToUniversalTime(); Log = "Testing API access for $($Tenant.defaultDomainName)" })

0 commit comments

Comments
 (0)