File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
Modules/CIPPCore/Public/Functions Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -111,18 +111,27 @@ function Get-CIPPTenantAlignment {
111111
112112 if ($Template.tenantFilter -and $Template.tenantFilter.Count -gt 0 ) {
113113 # Extract tenant values from the tenantFilter array
114- $TenantValues = $Template.tenantFilter | ForEach-Object {
115- if ($_.type -eq ' group' ) {
116- ($TenantGroups | Where-Object - Property GroupName -EQ $_.value ).Members.defaultDomainName
114+ $TenantValues = [System.Collections.Generic.List [string ]]::new()
115+ foreach ($filterItem in $Template.tenantFilter ) {
116+ if ($filterItem.type -eq ' group' ) {
117+ # Look up group members by Id (GUID in the value field)
118+ $GroupMembers = $TenantGroups | Where-Object { $_.Id -eq $filterItem.value }
119+ if ($GroupMembers -and $GroupMembers.Members ) {
120+ foreach ($member in $GroupMembers.Members.defaultDomainName ) {
121+ $TenantValues.Add ($member )
122+ }
123+ }
117124 } else {
118- $_ . value
125+ $TenantValues .Add ( $filterItem . value)
119126 }
120127 }
121128
122129 if ($TenantValues -contains ' AllTenants' ) {
123130 $AppliestoAllTenants = $true
131+ } elseif ($TenantValues.Count -gt 0 ) {
132+ $TemplateAssignedTenants = @ ($TenantValues )
124133 } else {
125- $TemplateAssignedTenants = $TenantValues
134+ $TemplateAssignedTenants = @ ()
126135 }
127136 } else {
128137 $AppliestoAllTenants = $true
You can’t perform that action at this time.
0 commit comments