diff --git a/src/internal/classes/AzOpsRoleEligibilityScheduleRequest.ps1 b/src/internal/classes/AzOpsRoleEligibilityScheduleRequest.ps1 index 47357a3a..cdc30cde 100644 --- a/src/internal/classes/AzOpsRoleEligibilityScheduleRequest.ps1 +++ b/src/internal/classes/AzOpsRoleEligibilityScheduleRequest.ps1 @@ -24,4 +24,25 @@ $this.Name = $roleEligibilitySchedule.Name $this.ResourceType = $roleEligibilityScheduleRequest.Type } + + AzOpsRoleEligibilityScheduleRequest($roleEligibilitySchedule) { + $this.Properties = [ordered]@{ + Condition = $roleEligibilitySchedule.Condition + ConditionVersion = $roleEligibilitySchedule.ConditionVersion + PrincipalId = $roleEligibilitySchedule.PrincipalId + RoleDefinitionId = $roleEligibilitySchedule.RoleDefinitionId + RequestType = "AdminAssign" + ScheduleInfo = [ordered]@{ + Expiration = [ordered]@{ + EndDateTime = $roleEligibilitySchedule.EndDateTime + Duration = $roleEligibilitySchedule.ExpirationDuration + ExpirationType = if ($roleEligibilitySchedule.ExpirationType) {$roleEligibilitySchedule.ExpirationType.ToString()} + } + StartDateTime = $roleEligibilitySchedule.StartDateTime + } + } + $this.Id = $roleEligibilitySchedule.RequestId + $this.Name = $roleEligibilitySchedule.Name + $this.ResourceType = "Microsoft.Authorization/roleEligibilityScheduleRequests" + } } \ No newline at end of file diff --git a/src/internal/functions/Get-AzOpsRoleEligibilityScheduleRequest.ps1 b/src/internal/functions/Get-AzOpsRoleEligibilityScheduleRequest.ps1 index ba32e11d..4e913597 100644 --- a/src/internal/functions/Get-AzOpsRoleEligibilityScheduleRequest.ps1 +++ b/src/internal/functions/Get-AzOpsRoleEligibilityScheduleRequest.ps1 @@ -35,6 +35,9 @@ Write-AzOpsMessage -LogLevel Debug -LogString 'Get-AzOpsRoleEligibilityScheduleRequest.Assignment' -LogStringValues $roleEligibilitySchedule.Name -Target $ScopeObject # Construct AzOpsRoleEligibilityScheduleRequest by combining information from roleEligibilitySchedule and roleEligibilityScheduleRequest [AzOpsRoleEligibilityScheduleRequest]::new($roleEligibilitySchedule, $roleEligibilityScheduleRequest) + else { + Write-AzOpsMessage -LogLevel Important -LogString 'Get-AzOpsRoleEligibilityScheduleRequest.Processing' -LogStringValues "No RoleEligibilityScheduleRequest found for RoleEligibilitySchedule in scope: $($ScopeObject.scope), creating template based on RoleEligibilitySchedule" -Target $ScopeObject + [AzOpsRoleEligibilityScheduleRequest]::new($roleEligibilitySchedule) } } }