Configuring Entra ID PIM for Just-in-Time Admin Access
A hands-on runbook for converting a standing Entra ID admin role into a time-bound, MFA-gated PIM eligible assignment with staged rollout and audit evidence.

In this lesson
Table of Contents
Table of contents
Before you begin
- Entra ID role-based access fundamentals
- Microsoft Graph PowerShell SDK basics
- Conditional Access and MFA registration concepts
Track this tutorial
Choose your current status and tick each safety check as you complete it. Sign in to sync progress between devices.
Current status
Tutorial stages
- Step 1: Confirm current assignment state
- Step 2: Configure the role management policy
- Step 3: Create the eligible assignment
- Step 4: Test activation as the end user
- Step 5: Stage the rollout beyond the test account
0 of 5 stages complete
Before you apply the change
Confirm these production-safety controls during the tutorial.
#Operational requirement
Standing admin roles are the most common finding in every identity security review KBY has run over the past three years. A Global Administrator or Exchange Administrator role sitting permanently active on a user account is a 24/7 attack surface. It does not matter how strong the password policy is if the account never has to prove it needs that privilege today. Microsoft Entra ID
The deliverable for this exercise is one Entra ID role — Exchange Administrator, used here as the working example — converted from a permanent active assignment to a time-bound eligible assignment with MFA-on-activation and manager approval enabled. You will finish with a documented activation test, a before-and-after policy record, and an audit log export proving the control actually works end to end, not just that a checkbox was ticked in the portal.
#Prerequisites and permissions
Confirm every item below before touching a production tenant. A missing licence or an incorrect delegated scope mid-change is the fastest way to turn a routine task into an unplanned outage.
| Requirement | Detail | Why it matters |
|---|---|---|
| Licensing | Entra ID P2 or Entra ID Governance assigned to the tenant | PIM is unavailable on P1 or Free; the blade shows a licensing upsell rather than the Roles list |
| Administrative role | Privileged Role Administrator or Global Administrator on your own account | Required to read and write PIM policies and eligibility schedules |
| Tooling | Microsoft Graph PowerShell SDK, module Microsoft.Graph version 2.x or later | The portal UI alone cannot produce machine-readable evidence for a change record |
| Delegated scopes | RoleManagement.ReadWrite.Directory, RoleManagementPolicy.ReadWrite.AzureADRoles, Directory.Read.All | Each cmdlet in this runbook fails or returns an access-denied response without the matching scope |
| Test account | A designated non-break-glass account with no existing assignment on Exchange Administrator | Keeps your baseline and your evidence pack uncontaminated by pre-existing state |
| Change record | Logged in your ITSM tool before Step 1 begins | PIM changes to administrative roles are exactly the class of change that gets audited retrospectively |
#Step 1: Confirm current assignment state
Before changing anything, capture the existing state so you have a rollback baseline. Connect to Graph with the correct scopes.
1Connect-MgGraph -Scopes "RoleManagement.ReadWrite.Directory","RoleManagementPolicy.ReadWrite.AzureADRoles","Directory.Read.All"
2
3Get-MgRoleManagementDirectoryRoleDefinition -Filter "displayName eq 'Exchange Administrator'" |
4 Select-Object Id, DisplayNameExpected result: a single role definition object with an Id in GUID format, for example 29232cdf-9323-42fd-ade2-1d097af3e4de. Record this GUID; you will reuse it in every subsequent call.
Evidence to capture: an export of current active assignments for that role definition.
1Get-MgRoleManagementDirectoryRoleAssignment -Filter "roleDefinitionId eq '29232cdf-9323-42fd-ade2-1d097af3e4de'" |
2 Select-Object PrincipalId, RoleDefinitionId, DirectoryScopeId |
3 Export-Csv -Path .pim-baseline-exchange-admin.csv -NoTypeInformationDo not proceed until this CSV is saved and attached to the change record. If the role already shows zero active assignments, note that explicitly — it changes your rollback plan later.

#Step 2: Configure the role management policy
PIM behaviour for a role is governed by a role management policy object, not by the assignment itself. This is the step most junior engineers skip, and it is why activations either sail through with no MFA prompt or sit stuck waiting for an approver nobody configured. Retrieve the policy assignment for the role.
1$policyAssignment = Get-MgPolicyRoleManagementPolicyAssignment -Filter "scopeId eq '/' and scopeType eq 'DirectoryRole' and roleDefinitionId eq '29232cdf-9323-42fd-ade2-1d097af3e4de'"
2$policyAssignment.PolicyIdUse the returned PolicyId to inspect and then update the rules that matter for a first rollout: the activation MFA requirement and the approval requirement.
1Get-MgPolicyRoleManagementPolicyRule -UnifiedRoleManagementPolicyId $policyAssignment.PolicyId |
2 Where-Object { $_.Id -like "Enablement_EndUser_Assignment" -or $_.Id -like "Approval_EndUser_Assignment" }Expected result: the Enablement rule lists required enablement rules including MultiFactorAuthentication; the Approval rule shows isApprovalRequired. If MFA is absent from the enablement list, update the rule with Update-MgPolicyRoleManagementPolicyRule to add it, and set a maximum activation duration — eight hours is a sane starting point for admin roles, not the default twelve or twenty-four. Save the JSON body of both rules before and after the change to your change record. Then confirm the approver group referenced in the approval rule actually exists and has at least two members. An approval rule pointing at an empty or deleted group locks activation permanently — this is one of the most common self-inflicted outages in PIM rollouts.
#Step 3: Create the eligible assignment
Convert your test account to eligible using a role eligibility schedule request. Note the endpoint name carefully: eligibility, not assignment.
1$params = @{
2 Action = "AdminAssign"
3 PrincipalId = "5c2f8a3b-91e6-4a2e-8ab0-cc112d7e0f31"
4 RoleDefinitionId = "29232cdf-9323-42fd-ade2-1d097af3e4de"
5 DirectoryScopeId = "/"
6 ScheduleInfo = @{
7 StartDateTime = (Get-Date).ToUniversalTime().ToString("o")
8 Expiration = @{
9 Type = "AfterDuration"
10 Duration = "P180D"
11 }
12 }
13 Justification = "Graduate onboarding task GTIT-4471 - eligible assignment for time-bound Exchange admin access"
14}
15New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest -BodyParameter $paramsExpected result: a response with Status equal to Provisioned and an Id for the schedule request. If you instead see PendingApprovalProvisioning, your tenant has an approval gate on eligibility creation itself, separate from activation approval — check the policy before assuming a fault. Capture the full response as JSON, plus a portal screenshot from Identity Governance, PIM, Microsoft Entra roles, Assignments, Eligible assignments, showing the new row with a 180-day expiry. Verify it shows under Eligible, not Active. If it shows Active, you used the assignment schedule endpoint by mistake — this is the single most frequent configuration error in this workflow.
#Step 4: Test activation as the end user
Sign in as the test account, or supervise the account owner doing so, and go to My Access, Privileged Identity Management, My roles, Microsoft Entra roles. Select Exchange Administrator and click Activate. Supply a justification string and complete the MFA challenge when prompted. If approval is required, the request moves to Pending and the approver receives a notification; once approved, the role becomes Active for the configured duration with a visible countdown. Capture the activation request Id, the approver’s decision timestamp, and the underlying audit entry.
1Get-MgAuditLogDirectoryAudit -Filter "activityDisplayName eq 'Add member to role completed (PIM activation)'" -Top 5 |
2 Select-Object ActivityDateTime, InitiatedBy, TargetResources#Step 5: Stage the rollout beyond the test account
Do not apply this pattern to the entire admin population in one change. Once the test account has activated, been approved, and expired correctly, repeat the eligibility assignment for one real administrator on a Friday afternoon with low change risk, not during a live incident window. Only after that second cycle produces the same clean evidence should you open a change request covering the remaining Exchange Administrator holders as a batch. A staged rollout catches approver-group and licensing gaps against a small blast radius instead of the whole administrative team.

#Verification
Retain the following as your closure pack for the change record: the pre-change CSV baseline from Step 1, the policy rule JSON before and after from Step 2, the eligibility schedule request response from Step 3, and the activation audit log entry from Step 4. Additionally, confirm the role auto-deprovisions by re-running the active-assignment query after the activation window elapses.
Get-MgRoleManagementDirectoryRoleAssignmentScheduleInstance -Filter "roleDefinitionId eq '29232cdf-9323-42fd-ade2-1d097af3e4de'"An empty result after expiry is the proof that matters. It demonstrates the time-bound control actually worked, not merely that it was configured with good intentions in a portal blade.
#Monitoring and change control
Configure an alert on the AuditLogs workspace for PIM activation and eligibility events so security operations sees activity outside business hours without waiting for a quarterly access review. Every future change to the role management policy — a new approver group, a longer activation duration, a scope change — must go through the same change record discipline used here: baseline captured, JSON before and after saved, evidence attached. Treat the approver group membership as a governed asset in its own right; review it on the same cadence as the access review for the role itself, because an empty approver group is a silent denial of service against your own administrators.
#Failure Modes and Common Traps
| Symptom | Likely cause | Fix |
|---|---|---|
| PIM blade shows a licensing prompt instead of the Roles list | Tenant lacks Entra ID P2 or Governance licence | Assign the licence to at least the administrator’s account; PIM checks tenant-level licensing in some configurations, not only per-user |
| Activation fails during an MFA-related sign-in step | Test account has no registered MFA method | Force MFA registration via the Authentication Methods policy before assigning eligibility |
| New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest returns a conflict indicating the assignment already exists | Principal already holds an active or eligible assignment for that role | Query existing schedules first and remove or expire the conflicting one before creating a new request |
| Approval request never resolves and activation sits Pending indefinitely | Approver group is empty or was deleted after policy configuration | Audit the approval rule’s approver list quarterly as part of the governance review cycle |
| Role reactivates instantly with no prompt at all | Enablement rule for MFA or justification was not actually saved on the policy | Re-run Get-MgPolicyRoleManagementPolicyRule and confirm the rule payload persisted; the portal UI occasionally shows stale state |
#Rollback
If the eligible assignment causes an operational problem — for example an approver group misconfiguration blocking a genuine incident responder — reverse it precisely. Do not delete things ad hoc.
- Identify the eligibility schedule request Id created in Step 3, then terminate it.
1$revoke = @{ 2 Action = "AdminRemove" 3 PrincipalId = "5c2f8a3b-91e6-4a2e-8ab0-cc112d7e0f31" 4 RoleDefinitionId = "29232cdf-9323-42fd-ade2-1d097af3e4de" 5 DirectoryScopeId = "/" 6} 7New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest -BodyParameter $revoke - Revert the role management policy rules to their pre-change values captured in Step 2’s JSON export, using Update-MgPolicyRoleManagementPolicyRule with the original payload.
- If the baseline in Step 1 showed a permanent active assignment prior to this change, restore it explicitly rather than assuming the tenant default.
1New-MgRoleManagementDirectoryRoleAssignment -BodyParameter @{ 2 PrincipalId = "5c2f8a3b-91e6-4a2e-8ab0-cc112d7e0f31" 3 RoleDefinitionId = "29232cdf-9323-42fd-ade2-1d097af3e4de" 4 DirectoryScopeId = "/" 5} - Close the change record noting the rollback reason and attach the terminated schedule request Id as evidence.
#Operational Summary
PIM does not make a tenant secure by existing — it makes a tenant secure when the activation controls are configured, tested with a real sign-in, and proven to expire. The pattern here — baseline, configure policy, create eligibility, test activation, stage the rollout, verify expiry, document rollback — applies unchanged whether you are onboarding Exchange Administrator, Security Administrator, or a custom role scoped to a single administrative unit. Treat every PIM change as you would a firewall rule change: assume it is wrong until you have evidence it behaves as intended under a real activation, not just a portal checkbox. The junior engineer who can produce that evidence pack unprompted is the one who gets handed the next privileged-role rollout without supervision.
#Learning Objectives
This enrichment extends the runbook's directory-role focus to two adjacent Entra ID capabilities that a junior engineer will meet almost immediately once the Exchange Administrator pattern is proven: Privileged Identity Management for Groups, and PIM applied to Azure resource roles. Both use the same eligibility-and-activation model but expose different cmdlets, different scope objects, and different failure surfaces, so recognising the pattern rather than memorising a single command sequence is the actual skill being tested here.
On completion, the engineer should be able to distinguish a directory-role eligibility schedule from a group-based eligibility schedule at the API level, identify which scope object (DirectoryScopeId versus a subscription or resource-group resourceId) each request requires, and produce the same before-and-after evidence pack — baseline export, policy JSON, activation audit entry, and post-expiry verification — for a resource that is not a Microsoft Entra role at all.
- Distinguish PIM for Entra roles from PIM for Groups and PIM for Azure resources at the Graph API and scope-object level
- Apply the eligibility-schedule-request pattern to a Microsoft 365 or security group carrying delegated privilege
- Produce audit evidence for a resource-scoped activation, not only a tenant-scoped one
- Identify the correct rollback action (AdminRemove) for a group-based eligibility request versus a role-based one
#Worked Example
A common escalation beyond the Exchange Administrator case is a Microsoft 365 group that has itself been assigned an Azure resource role (for example, Contributor on a subscription) and is also enabled for PIM for Groups. Membership or ownership of that group becomes eligible rather than standing, using a parallel but distinct endpoint: New-MgIdentityGovernancePrivilegedAccessGroupEligibilityScheduleRequest. The AccessId parameter must be set to 'member' or 'owner', and the GroupId replaces RoleDefinitionId as the object being scoped.
Before creating the request, capture the current membership state with Get-MgGroupMember on the target group and export it to CSV, exactly as Step 1 of the base runbook does for role assignments — this is the rollback baseline for a group, not a role. Run the eligibility request with a bounded Duration (for example P90D) and a Justification string tied to a change record, then validate with Get-MgIdentityGovernancePrivilegedAccessGroupAssignmentScheduleInstance filtered on the GroupId; a Status of Provisioned and an eligible (not active) entry confirms correct configuration.
To validate activation, the account owner must go to My Access, Privileged Identity Management, My roles, Groups, and activate membership; the resulting audit entry appears under the same Get-MgAuditLogDirectoryAudit query used in the base runbook, filtered instead on the group's object Id in TargetResources. If the group does not appear under My roles at all, PIM for Groups has not been enabled on that specific group in Identity Governance, Privileged Access, Groups — this is a separate on/off setting per group and is not inherited from the tenant's PIM licence alone.
Rollback for this scenario uses the same AdminRemove Action pattern as the base runbook's role rollback, but against New-MgIdentityGovernancePrivilegedAccessGroupEligibilityScheduleRequest with the original GroupId and AccessId. Confirm rollback succeeded by re-running Get-MgGroupMember and diffing against the Step-1 CSV baseline; any discrepancy means the removal did not fully propagate and must be re-run before closing the change record.
#Practice Exercise
In a non-production tenant, identify one Azure resource role (Reader is sufficient) assigned to a security group, and enable that group for PIM for Groups under Identity Governance, Privileged Access, Groups. Export the current member list before making any change, exactly as you would for a directory-role baseline.
Convert one test account's membership from active to eligible with a 30-day duration and an MFA-on-activation enablement rule, then activate it as the end user and capture the activation audit entry. Verify the resource role is only usable during the active membership window by attempting a read operation against the scoped resource before and after activation, and record both outcomes as evidence.
Finally, allow the eligibility window to lapse (or force expiry for testing purposes) and re-run the membership export to confirm the account has been automatically removed from the group. An unchanged membership list after expiry indicates the control has not actually enforced time-bound access, and should be treated as a failed test requiring investigation before the pattern is rolled out further.
Evidence trail
Sources and verification
Primary documentation and external technical references used in this article.
Comments
Add a thoughtful note on Configuring Entra ID PIM for Just-in-Time Admin Access. Comments are checked for spam and held for moderation before appearing.
Related articles
Identity and Access Management
Configuring Entra ID Cross-Tenant Access for B2B Guests
A hands-on runbook for junior engineers locking down Entra ID cross-tenant access, inbound MFA trust and Conditional Access before B2B guest onboarding.
Enterprise IT Management
Designing a Verifiable IT Management Workflow with Microsoft 365
A bounded Microsoft 365 Conditional Access workflow: staged rollout through report-only evaluation and pilot enforcement, explicit validation gates, and a rehearsed, non-destructive rollback path.
Enterprise IT Management
Continuous Control Monitoring for SOC 2 Audits
How AWS Config, Okta logs and GitHub audit events feed a continuous control monitoring pipeline that replaces manual SOC 2 evidence pulls.
Discover more
Graduate Learning
Ops Playbook
Lexicon Definitions
Learn More About KBY
About KBY
Learn about our mission, editorial standards, and commitment to trusted engineering knowledge.
Why Trust KBY
Explore the processes and policies that ensure our publications are accurate, useful, and responsible.
Newsletter
Get our latest editorial publications, research and practical insights sent directly to your inbox.
Was this useful?
Build practical engineering skills.
Receive new lessons, learning paths, practical exercises and early-career guidance.