Need help in setting the duration for role assignment using Azure PIM
SR VSP
1,226
Reputation points
Team,
Can you help setting the correct time duration for a specific user like Ex: 4 hrs OR 12 hrs or 24hrs . Below code i'm using not working as expected for the time stamp.
It should always set the current system time.
Open-AzureADMSPrivilegedRoleAssignmentRequest -ProviderId 'aadRoles' -ResourceId 'fb108fc9-23c2-4d1e-b22e-ff2ew77623da' -RoleDefinitionId 'fe430be4-5e62-47db-91af-98c3a49a38b1' -SubjectId '504f2f84-5aa4-42e8-99eb-d1a509f69f78' -Type 'adminAdd' -AssignmentState 'Eligible' -schedule $schedule -reason "test using powershell"
**$Duration = 4 # Number in Hours**
$Date = Get-Date
$start = $Date.ToUniversalTime()
$end = $Date.AddHours($Duration).ToUniversalTime()
$schedule = New-Object Microsoft.Open.MSGraph.Model.AzureADMSPrivilegedSchedule
$schedule.Type = 'Once'
$schedule.StartDateTime = $start.ToString('yyyy-MM-ddTHH:mm:ss.fffZ')
$schedule.endDateTime = $end.ToString('yyyy-MM-ddTHH:mm:ss.fffZ')