My tenants required Ticket number when we trying to activate PIM role in Azure Portal and I understand there there is no way to pass ticket parameter right now in PowerShell but I'm just wondering if there is work around?.
Connect-AzureAD
# find your guids once and fill in the values
$values = [PSCustomObject]@{
Reason = "Support"
Hours = 2
ResourceId = ""
SubjectId = ""
RoleDefinitionId = ""
}
$schedule = New-Object Microsoft.Open.MSGraph.Model.AzureADMSPrivilegedSchedule
$schedule.Type = "Once"
$now = (Get-Date).ToUniversalTime()
$schedule.StartDateTime = $now.ToString("yyyy-MM-ddTHH:mm:ss.fffZ")
$schedule.EndDateTime = $now.AddHours($values.Hours).ToString("yyyy-MM-ddTHH:mm:ss.fffZ")
Open-AzureADMSPrivilegedRoleAssignmentRequest `
-ProviderId 'aadRoles' `
-ResourceId $values.ResourceId `
-RoleDefinitionId $values.RoleDefinitionId `
-SubjectId $values.SubjectId `
-Type 'UserAdd' `
-AssignmentState 'Active' `
-Schedule $schedule `
-Reason $values.Reason