How to activate PIM role using PowerShell

Aase Nomad 246 Reputation points
2022-02-17T23:43:55.793+00:00

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
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,508 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,221 Reputation points
    2022-02-23T15:12:06.813+00:00

    Hello @Aase Nomad

    Since this involves the need of a functionality using Microsoft Graph, I will recommend to post your question in the Graph support developer site

    https://developer.microsoft.com/en-us/graph/support

    Hope this helps with your query,

    --
    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.