@@ -120,39 +120,19 @@ function Set-CIPPAuthenticationPolicy {
120120 }
121121 }
122122
123- if ($PSBoundParameters.ContainsKey (' GroupIds' ) -and @ ($GroupIds ).Count -gt 0 ) {
124- $ResolvedGroupIds = @ (
125- @ ($GroupIds ) |
126- ForEach-Object { " $_ " .Trim() } |
127- Where-Object { -not [string ]::IsNullOrWhiteSpace($_ ) } |
128- Select-Object - Unique
129- )
130-
131- if ($ResolvedGroupIds.Count -gt 0 ) {
132- $TargetTemplate = $null
133- if ($CurrentInfo.includeTargets -and @ ($CurrentInfo.includeTargets ).Count -gt 0 ) {
134- $TargetTemplate = $CurrentInfo.includeTargets | Select-Object - First 1
135- }
136-
137- $CurrentInfo.includeTargets = @ (
138- foreach ($GroupId in $ResolvedGroupIds ) {
139- $TargetProperties = [ordered ]@ {}
140- if ($TargetTemplate ) {
141- foreach ($Property in $TargetTemplate.PSObject.Properties ) {
142- if ($Property.Name -ne ' id' -and $Property.Name -ne ' targetType' ) {
143- $TargetProperties [$Property.Name ] = $Property.Value
144- }
145- }
146- }
147- $TargetProperties.targetType = ' group'
148- $TargetProperties.id = $GroupId
149- [pscustomobject ]$TargetProperties
123+ if ($PSBoundParameters.ContainsKey (' GroupIds' ) -and $GroupIds ) {
124+ $CurrentInfo.includeTargets = @ (
125+ foreach ($id in $GroupIds ) {
126+ [pscustomobject ]@ {
127+ targetType = ' group'
128+ id = $id
150129 }
151- )
152- $OptionalLogMessage = " $OptionalLogMessage and targeted groups set to $ ( $ResolvedGroupIds -join ' , ' ) "
153- }
130+ }
131+ )
132+ $OptionalLogMessage += " and targeted groups set to $ ( $CurrentInfo .includeTargets.id -join ' , ' ) "
154133 }
155134
135+
156136 # Set state of the authentication method
157137 try {
158138 if ($PSCmdlet.ShouldProcess ($AuthenticationMethodId , " Set state to $State $OptionalLogMessage " )) {
0 commit comments