From 025d4e2aa2652558b5ad41dae74191c7a3daca0c Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Tue, 14 Nov 2023 13:53:54 -0800 Subject: [PATCH] Release 1.23.1108.3 --- CHANGELOG.md | 2 +- ...SFT_AADRoleEligibilityScheduleRequest.psm1 | 42 +++++++++++-------- Modules/Microsoft365DSC/Microsoft365DSC.psd1 | 2 +- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62d3aa0509..2af87cc081 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change log for Microsoft365DSC -# 1.23.1108.2 +# 1.23.1108.3 * AADRoleEligibilityScheduleRequest * Fixed incorrect subclass MSFT_AADRoleEligibilityScheduleRequestScheduleRecurrenceRange diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleEligibilityScheduleRequest/MSFT_AADRoleEligibilityScheduleRequest.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleEligibilityScheduleRequest/MSFT_AADRoleEligibilityScheduleRequest.psm1 index bc1b1f37e8..75a152c5a8 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleEligibilityScheduleRequest/MSFT_AADRoleEligibilityScheduleRequest.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleEligibilityScheduleRequest/MSFT_AADRoleEligibilityScheduleRequest.psm1 @@ -110,17 +110,17 @@ { if ($null -ne $Script:exportedInstances -and $Script:ExportMode) { - [Array]$request = $Script:exportedInstances | Where-Object -FilterScript {$_.Id -eq $Id} + $request = $Script:exportedInstances | Where-Object -FilterScript {$_.Id -eq $Id} } else { Write-Verbose -Message "Getting Role Eligibility by Id {$Id}" - [Array]$request = Get-MgBetaRoleManagementDirectoryRoleEligibilityScheduleRequest -UnifiedRoleEligibilityScheduleRequestId $Id ` + $request = Get-MgBetaRoleManagementDirectoryRoleEligibilityScheduleRequest -UnifiedRoleEligibilityScheduleRequestId $Id ` -ErrorAction SilentlyContinue } } - if ($null -eq $request -or $request.Length -eq 0) + if ($null -eq $request) { if ($null -ne $Script:exportedInstances -and $Script:ExportMode) { @@ -146,7 +146,7 @@ } Write-Verbose -Message "Found Principal {$PrincipalId}" $RoleDefinitionId = (Get-MgBetaRoleManagementDirectoryRoleDefinition -Filter "DisplayName eq '$RoleDefinition'").Id - [Array]$request = $Script:exportedInstances | Where-Object -FilterScript {$_.PrincipalId -eq $PrincipalId -and $_.RoleDefinitionId -eq $RoleDefinition} + $request = $Script:exportedInstances | Where-Object -FilterScript {$_.PrincipalId -eq $PrincipalId -and $_.RoleDefinitionId -eq $RoleDefinition} } else { @@ -178,15 +178,15 @@ Write-Verbose -Message "Found Role {$RoleDefinitionId}" $schedule = Get-MgBetaRoleManagementDirectoryRoleEligibilitySchedule -Filter "PrincipalId eq '$PrincipalId' and RoleDefinitionId eq '$RoleDefinitionId'" - [Array]$request = Get-MgBetaRoleManagementDirectoryRoleEligibilityScheduleRequest -Filter "PrincipalId eq '$PrincipalId' and RoleDefinitionId eq '$RoleDefinitionId'" + $request = Get-MgBetaRoleManagementDirectoryRoleEligibilityScheduleRequest -Filter "PrincipalId eq '$PrincipalId' and RoleDefinitionId eq '$RoleDefinitionId'" } } else { $RoleDefinitionId = (Get-MgBetaRoleManagementDirectoryRoleDefinition -Filter "DisplayName eq '$RoleDefinition'").Id - $schedule = Get-MgBetaRoleManagementDirectoryRoleEligibilitySchedule -Filter "PrincipalId eq '$($request[0].PrincipalId)' and RoleDefinitionId eq '$RoleDefinitionId'" + $schedule = Get-MgBetaRoleManagementDirectoryRoleEligibilitySchedule -Filter "PrincipalId eq '$($request.PrincipalId)' and RoleDefinitionId eq '$RoleDefinitionId'" } - if ($null -eq $schedule -or $null -eq $request -or $request.Length -eq 0) + if ($null -eq $schedule -or $null -eq $request) { return $nullResult } @@ -194,12 +194,18 @@ Write-Verbose -Message "Found existing AADRolelLigibilityScheduleRequest" if ($PrincipalType -eq 'User') { - $PrincipalInstance = Get-MgUser -UserId $request[0].PrincipalId -ErrorAction SilentlyContinue + $PrincipalInstance = Get-MgUser -UserId $request.PrincipalId -ErrorAction SilentlyContinue $PrincipalTypeValue = 'User' } if ($null -eq $PrincipalInstance -or $PrincipalType -eq 'Group') { - $PrincipalInstance = Get-MGGroup -GroupId $request[0].PrincipalId -ErrorAction SilentlyContinue + $requestArray = [Array]$request + if ($requestArray.Count -gt 1) + { + $requestArray = $requestArray | Sort-Object -Property CreatedDateTime -Descending + $request = $requestArray[0] + } + $PrincipalInstance = Get-MGGroup -GroupId $request.PrincipalId -ErrorAction SilentlyContinue $PrincipalTypeValue = 'Group' } @@ -250,11 +256,11 @@ } $ticketInfoValue = $null - if ($null -ne $request[0].TicketInfo) + if ($null -ne $request.TicketInfo) { $ticketInfoValue = @{ - ticketNumber = $request[0].TicketInfo.TicketNumber - ticketSystem = $request[0].TicketInfo.TicketSystem + ticketNumber = $request.TicketInfo.TicketNumber + ticketSystem = $request.TicketInfo.TicketSystem } } @@ -272,12 +278,12 @@ Principal = $PrincipalValue PrincipalType = $PrincipalTypeValue RoleDefinition = $RoleDefinition - DirectoryScopeId = $request[0].DirectoryScopeId - AppScopeId = $request[0].AppScopeId - Action = $request[0].Action - Id = $request[0].Id - Justification = $request[0].Justification - IsValidationOnly = $request[0].IsValidationOnly + DirectoryScopeId = $request.DirectoryScopeId + AppScopeId = $request.AppScopeId + Action = $request.Action + Id = $request.Id + Justification = $request.Justification + IsValidationOnly = $request.IsValidationOnly ScheduleInfo = $ScheduleInfoValue TicketInfo = $ticketInfoValue Ensure = 'Present' diff --git a/Modules/Microsoft365DSC/Microsoft365DSC.psd1 b/Modules/Microsoft365DSC/Microsoft365DSC.psd1 index ef2770db41..a3983b478c 100644 --- a/Modules/Microsoft365DSC/Microsoft365DSC.psd1 +++ b/Modules/Microsoft365DSC/Microsoft365DSC.psd1 @@ -11,7 +11,7 @@ # RootModule = '' # Version number of this module. - ModuleVersion = '1.23.1108.2' + ModuleVersion = '1.23.1108.3' # Supported PSEditions # CompatiblePSEditions = @()