Lab Metadata
Core technologies
Scenario and Description
Your Lab 01 baseline listed Northgate's privileged role holders. Every one of them holds their admin role permanently, active every second of every day, whether they are performing an admin task or asleep. That is standing privilege, and it is the single largest movement in an attacker's favour: compromise any one of those accounts at any time and you inherit live admin rights immediately.
Privileged Identity Management (PIM) breaks this model. Instead of being permanently active in a role, an administrator is made eligible for it. When they need it, they activate the role for a bounded window, providing a justification, passing MFA, and, for the most sensitive roles, waiting for approval. When the window expires, the privilege evaporates. The account spends almost all of its life with no admin rights at all, so a stolen credential is worth far less.
This is the heart of the brief's requirement to "support the deployment and optimisation of Privileged Access Management" and to "implement least-privilege access principles". You will inventory standing privilege, tune the role activation policy, convert an administrator from permanently active to eligible, activate just-in-time as that user, and, crucially, keep your break-glass accounts as a deliberate exception so an emergency is never blocked by an activation workflow.
Prerequisites
Prior labs
Labs 01 and 03 required. You use the jpatel administrator from Lab 01 and the break-glass accounts from Lab 03. PIM requires Entra ID P2, which your Lab 01 trial provides.
Graph scopes introduced
| Scope | Why it is needed |
|---|---|
RoleManagement.ReadWrite.Directory | Read assignments, create eligibility, activate and remove role assignments |
RoleManagementPolicy.ReadWrite.Directory | Read and adjust role activation policies |
Directory.Read.All | Resolve role definitions and principals |
Real-World Problem Statement
Least privilege is not only about which roles someone has, it is about when they have them. A role held permanently is a role available to an attacker permanently. Reducing the time privilege is active is often a bigger risk reduction than reducing the number of people who hold it.
| Dimension | Why this matters |
|---|---|
| Risk | Standing admin rights are always-on attack value. JIT activation shrinks the window in which a compromised admin account is actually privileged to near zero. |
| Compliance | Time-bound, justified, approved privileged access with a full activation audit trail is a core control auditors look for. |
| Productivity | Activation takes seconds, and admins keep a clean record of exactly when and why they used privilege. |
| Security posture | This is the move that turns a list of permanent admins into a set of occasional, accountable elevations. |
Concrete scenario: Northgate has 14 permanent administrators across sensitive roles. The CISO wants none of them permanently active by quarter end. Every elevation must require MFA and a justification, Global Administrator activations must require approval, and break-glass must remain instantly usable outside the whole workflow.
Skills Mapped to Production Solutions
| Skill learned in this lab | Real-world enterprise application |
|---|---|
| Inventorying standing versus eligible privilege | Measuring and reducing the permanent-admin attack surface |
| Tuning role activation policies | Enforcing MFA, justification, duration and approval on elevation |
| Converting active assignments to eligible | Rolling out just-in-time access across an admin population |
| Self-activating a role via Graph and portal | Day-to-day privileged operations under least privilege |
| Designing the break-glass exception | Guaranteeing emergency access survives the privileged-access model |
Architecture Overview
PIM introduces two states for a role: eligible (you may activate it) and active (you currently hold it). Administrators live in the eligible state and activate briefly on demand. Break-glass accounts stay permanently active, outside the workflow.
Step-by-Step Implementation
Phase A - Inventory standing privilege
1List permanent active role assignments
Purpose: identify who holds admin rights permanently, the population to convert.
Enumerate active assignments and resolve names
Connect-MgGraph -Scopes 'RoleManagement.ReadWrite.Directory',
'RoleManagementPolicy.ReadWrite.Directory','Directory.Read.All' -NoWelcome
# Active (currently effective) directory role assignments.
$assignments = Get-MgRoleManagementDirectoryRoleAssignment -All -ExpandProperty Principal
$assignments | ForEach-Object {
$roleDef = Get-MgRoleManagementDirectoryRoleDefinition -UnifiedRoleDefinitionId $_.RoleDefinitionId
[pscustomobject]@{
Role = $roleDef.DisplayName
Principal = $_.Principal.AdditionalProperties['userPrincipalName']
Type = ($_.Principal.AdditionalProperties['@odata.type'] -replace '#microsoft.graph.','')
AssignmentId = $_.Id
}
} | Sort-Object Role | Format-Table -AutoSize
Phase B - Tune the activation policy
2Set the role activation rules
Purpose: require MFA, justification, a bounded duration, and approval for the most sensitive roles.
Context: each role has a role management policy governing activation. The rule set is fiddly to edit purely in Graph, so tune it in the portal with the precise settings below, and read it back via Graph to confirm.
Portal settings, then read the policy via Graph
# PORTAL: entra.microsoft.com > ID Governance > Privileged Identity Management > # Microsoft Entra roles > Settings > select 'User Administrator' > Edit. # # Activation: # Maximum activation duration = 8 hours # Require multi-factor authentication on activation = Yes # Require justification on activation = Yes # Require approval to activate = No (for User Administrator) # # For 'Global Administrator', repeat with: # Require approval to activate = Yes, and name specific approvers. # Require phishing-resistant MFA (ties to Lab 04) if configured. # # READ BACK via Graph to confirm the policy exists for the role scope: $polAssign = Get-MgPolicyRoleManagementPolicyAssignment ` -Filter "scopeId eq '/' and scopeType eq 'DirectoryRole' and roleDefinitionId eq 'fe930be7-5e62-47db-91af-98c3a49a38b1'" Get-MgPolicyRoleManagementPolicyRule -UnifiedRoleManagementPolicyId $polAssign.PolicyId | Select-Object Id, AdditionalProperties
Phase C - Make jpatel eligible, then remove standing access
3Create an eligible assignment for User Administrator
Purpose: give jpatel the ability to activate the role on demand, before removing the permanent one.
Create the eligibility via a schedule request
$domain = (Get-MgOrganization).VerifiedDomains | Where-Object IsDefault | Select-Object -ExpandProperty Name $jpatel = Get-MgUser -Filter "userPrincipalName eq 'jpatel@$domain'" $roleDefId = 'fe930be7-5e62-47db-91af-98c3a49a38b1' # User Administrator New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest -BodyParameter @{ action = 'adminAssign' principalId = $jpatel.Id roleDefinitionId = $roleDefId directoryScopeId = '/' justification = 'Move jpatel to eligible JIT for User Administrator' scheduleInfo = @{ startDateTime = (Get-Date).ToString('o') expiration = @{ type = 'noExpiration' } # eligibility persists; recertified via access reviews (Lab 08) } }
Get-MgRoleManagementDirectoryRoleEligibilitySchedule `
-Filter "principalId eq '$($jpatel.Id)'" |
Select-Object RoleDefinitionId, Status, MemberType
# Expected: an eligibility schedule for the User Administrator role.
4Remove the permanent active assignment
Purpose: take away the always-on rights now that jpatel can activate on demand.
Delete the standing assignment (only after eligibility is confirmed)
# Find jpatel's permanent active User Administrator assignment. $perm = Get-MgRoleManagementDirectoryRoleAssignment -All ` -Filter "principalId eq '$($jpatel.Id)' and roleDefinitionId eq '$roleDefId'" # Remove it. jpatel now holds the role only when activated. if ($perm) { Remove-MgRoleManagementDirectoryRoleAssignment -UnifiedRoleAssignmentId $perm.Id Write-Host 'Permanent User Administrator assignment removed for jpatel.' -ForegroundColor Green }
What just happened? jpatel has gone from permanently privileged to occasionally privileged. Their account now spends most of its life with no admin rights, so a credential theft yields far less, and any use of privilege is a deliberate, logged act.
Phase D - Activate just-in-time
5Self-activate the role for a bounded window
Purpose: experience the day-to-day flow, elevate briefly with a justification, then let it expire.
Context: activation is performed by the user themselves. jpatel does this from the portal or via Graph while signed in as jpatel.
Activate via the portal, or via Graph as jpatel
# PORTAL (as jpatel): entra.microsoft.com > PIM > My roles > # Microsoft Entra roles > Eligible assignments > User Administrator > Activate. # Provide a justification, complete MFA, choose a duration up to 8 hours. # # GRAPH (signed in as jpatel): $me = Get-MgUser -UserId (Get-MgContext).Account New-MgRoleManagementDirectoryRoleAssignmentScheduleRequest -BodyParameter @{ action = 'selfActivate' principalId = $me.Id roleDefinitionId = 'fe930be7-5e62-47db-91af-98c3a49a38b1' directoryScopeId = '/' justification = 'Onboarding three new joiners this afternoon' scheduleInfo = @{ startDateTime = (Get-Date).ToString('o') expiration = @{ type = 'afterDuration'; duration = 'PT8H' } # 8-hour window } }
# As an admin, confirm the active (activated) instance and its expiry: Get-MgRoleManagementDirectoryRoleAssignmentScheduleInstance ` -Filter "principalId eq '$($jpatel.Id)'" | Select-Object RoleDefinitionId, StartDateTime, EndDateTime, AssignmentType # AssignmentType 'Activated' with an EndDateTime ~8 hours out.
What just happened? jpatel elevated for a defined window with a recorded reason. When the window closes, the rights disappear automatically with no cleanup needed. The activation, the justification and the expiry are all in the audit log, ready for review.
Phase E - Protect the break-glass exception
6Confirm break-glass stays permanently active
Purpose: ensure your emergency path is not accidentally swept into PIM.
Verify break-glass holds permanent Global Administrator
foreach ($n in 1..2) {
$bg = Get-MgUser -Filter "userPrincipalName eq 'breakglass$n@$domain'"
$a = Get-MgRoleManagementDirectoryRoleAssignment -All -Filter "principalId eq '$($bg.Id)'"
[pscustomobject]@{
Account = $bg.UserPrincipalName
HasPermanentRole = [bool]$a
}
} | Format-Table -AutoSize
# Expected: HasPermanentRole = True for both break-glass accounts.
Testing and Validation
- Eligibility: confirm jpatel appears under eligible assignments and holds no active User Administrator rights when not activated.
- Activation: as jpatel, activate the role with a justification and MFA, then confirm an active instance exists with an expiry.
- Expiry: after the window (or by ending the activation early), confirm the active instance is gone and rights are removed.
- Approval (Global Admin): configure approval on Global Administrator, request activation, and confirm it waits for approver action.
- Break-glass: confirm both emergency accounts still hold permanent Global Administrator outside PIM.
| Symptom | Cause | Resolution |
|---|---|---|
| jpatel cannot activate | No eligible assignment, or activation policy blocks them | Confirm the eligibility schedule and that MFA and justification are satisfiable |
| Activation succeeds but no rights | Directory replication delay | Allow a short propagation window, then re-check |
| Cannot remove permanent assignment | It is the last Global Administrator, or a protected assignment | Never remove the last standing GA, keep break-glass and at least one recoverable path |
| Policy read returns nothing | Wrong role definition id or scope in the filter | Use the correct template id and scope / |
Security Analysis
What makes this sound
- Minimised standing privilege: admins are eligible, not active, so a stolen credential is rarely privileged at the moment of theft.
- Gated elevation: MFA, justification and, for top roles, approval, ensure every activation is accountable.
- Automatic expiry: time-bound activation removes the risk of forgotten standing rights.
- Preserved recovery: break-glass stays outside PIM so emergencies are never blocked.
Intentionally simplified for the lab
- Policy tuning is done in the portal. Production teams often manage these policies as code, which is more involved via Graph.
- A single role is converted. Real rollouts convert every privileged role and use PIM for groups too.
Production hardening
- Require phishing-resistant MFA (Lab 04) on activation of the most sensitive roles.
- Alert on every Global Administrator activation and on any new permanent role assignment, which should now be rare.
- Recertify eligibility with access reviews (Lab 08) so eligible does not quietly become forever.
Cleanup Instructions
Restore a permanent assignment and remove eligibility (reset only)
$domain = (Get-MgOrganization).VerifiedDomains | Where-Object IsDefault | Select-Object -ExpandProperty Name $jpatel = Get-MgUser -Filter "userPrincipalName eq 'jpatel@$domain'" $roleDefId = 'fe930be7-5e62-47db-91af-98c3a49a38b1' # Recreate a permanent active assignment if you want jpatel back to standing admin. New-MgRoleManagementDirectoryRoleAssignmentScheduleRequest -BodyParameter @{ action='adminAssign'; principalId=$jpatel.Id; roleDefinitionId=$roleDefId; directoryScopeId='/' justification='reset'; scheduleInfo=@{ startDateTime=(Get-Date).ToString('o'); expiration=@{ type='noExpiration' } } } # Remove the eligibility. New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest -BodyParameter @{ action='adminRemove'; principalId=$jpatel.Id; roleDefinitionId=$roleDefId; directoryScopeId='/' justification='reset' } Disconnect-MgGraph
Recommended Learning Links
Key Takeaways and Next Lab
- Least privilege includes time: standing admin rights are always-on risk, eligibility plus activation removes it.
- Gate activation with MFA, justification and, for the highest roles, approval, and bound it in time.
- Make people eligible before removing standing access, availability before removal.
- Break-glass accounts stay permanently active and outside PIM by design.
Identity Bytes // IB-ENTRA-SEC Track // Lab 07 of 12. British English. For lab and training use against a disposable tenant only.