Skip to content

Fix Azure PIM catch-22: discover eligible roles without standing subscription access#9

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/feature-pimactivation-azure-role-assignments
Draft

Fix Azure PIM catch-22: discover eligible roles without standing subscription access#9
Copilot wants to merge 2 commits intomainfrom
copilot/feature-pimactivation-azure-role-assignments

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 9, 2026

Users with zero standing Azure access hit a dead end: Get-AzSubscription requires subscription read rights, but subscription access requires activating a PIM role, which requires discovering eligible roles first.

Changes

  • Get-AzureResourceRoles.ps1
    • Changed Get-AzSubscription -ErrorAction Stop@(Get-AzSubscription -ErrorAction SilentlyContinue) — eliminates the throw when the account has no subscription visibility
    • Added ARM REST API fallback when no subscriptions are returned: calls Invoke-AzRestMethod at tenant scope to enumerate eligible role assignments — this endpoint requires only an authenticated context, not subscription read access
    • GUID-validates UserObjectId before embedding in the OData filter string
# Tenant-level query — works with zero standing subscription access
Invoke-AzRestMethod -Method GET `
    -Path "/providers/Microsoft.Authorization/roleEligibilitySchedules?api-version=2020-10-01&`$filter=principalId eq '$UserObjectId'"

The fallback returns the same role object shape as the normal subscription-enumeration path, so downstream consumers are unaffected.

Copilot AI linked an issue Apr 9, 2026 that may be closed by this pull request
…n access

Agent-Logs-Url: https://github.com/Noble-Effeciency13/PIMActivation/sessions/e658c903-7cea-4e1b-9ef7-d05929e976f6

Co-authored-by: Noble-Effeciency13 <84348626+Noble-Effeciency13@users.noreply.github.com>
Copilot AI changed the title [WIP] Add PIMActivation to pull eligible Azure role assignments Fix Azure PIM catch-22: discover eligible roles without standing subscription access Apr 9, 2026
Copilot AI requested a review from Noble-Effeciency13 April 9, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]

2 participants