Skip to content

Commit a7aee30

Browse files
committed
feat: tenant group support in standards
1 parent 48e15d5 commit a7aee30

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ function Get-TenantGroups {
1818
$GroupTable = Get-CippTable -tablename 'TenantGroups'
1919
$MembersTable = Get-CippTable -tablename 'TenantGroupMembers'
2020

21-
if ($TenantFilter) {
21+
if ($TenantFilter -and $TenantFilter -ne 'allTenants') {
2222
$TenantParams = @{
23-
TenantFilter = $TenantFilter
23+
TenantFilter = $TenantFilter
2424
IncludeErrors = $true
2525
}
2626
} else {
@@ -42,7 +42,7 @@ function Get-TenantGroups {
4242
return @()
4343
}
4444

45-
if ($TenantFilter) {
45+
if ($TenantFilter -and $TenantFilter -ne 'allTenants') {
4646
$Memberships = $AllMembers | Where-Object { $_.customerId -eq $Tenants.customerId }
4747
foreach ($Group in $Memberships) {
4848
$Group = $Groups | Where-Object { $_.RowKey -eq $Group.GroupId }

Modules/CIPPCore/Public/Standards/Get-CIPPStandards.ps1

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ function Get-CIPPStandards {
1313
$runManually = $false
1414
)
1515

16+
# Get tenant groups
17+
$TenantGroups = Get-TenantGroups
18+
1619
# 1. Get all JSON-based templates from the "templates" table
1720
$Table = Get-CippTable -tablename 'templates'
1821
$Filter = "PartitionKey eq 'StandardsTemplateV2'"
@@ -116,11 +119,21 @@ function Get-CIPPStandards {
116119
# 4. For each tenant, figure out which templates apply, merge them, and output.
117120
foreach ($Tenant in $AllTenantsList) {
118121
$TenantName = $Tenant.defaultDomainName
119-
120122
# Determine which templates apply to this tenant
121123
$ApplicableTemplates = $Templates | ForEach-Object {
122124
$template = $_
123-
$tenantFilterValues = $template.tenantFilter | ForEach-Object { $_.value }
125+
$tenantFilterValues = $template.tenantFilter | ForEach-Object {
126+
$FilterValue = $_.value
127+
# Group lookup
128+
if ($_.type -eq 'Group') {
129+
($TenantGroups | Where-Object {
130+
$_.Id -eq $FilterValue
131+
}).Members.defaultDomainName
132+
} else {
133+
$FilterValue
134+
}
135+
}
136+
124137
$excludedTenantValues = @()
125138

126139
if ($template.excludedTenants) {

0 commit comments

Comments
 (0)