Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"action": "selfActivate",
"principalId": "11111111-1111-1111-1111-111111111111",
"roleDefinitionId": "8424c6f0-a189-499e-bbd0-26c1753c96d4",
"directoryScopeId": "/",
"justification": "Activation requested from metadata.json",
"scheduleInfo": {
"startDateTime": "2026-05-26T00:00:00Z",
"expiration": {
"type": "AfterDuration",
"duration": "PT5H"
}
},
"ticketInfo": {
"ticketNumber": "AKHIL-ATTR-0001",
"ticketSystem": "QIH3B"
}
}
38 changes: 23 additions & 15 deletions entra-pim-self-activate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -478,22 +478,30 @@ catch {

Write-Host "`n[5/6] Submitting self-activation request..." -ForegroundColor Cyan

$params = @{
action = "selfActivate"
principalId = $principalId
roleDefinitionId = $Config.RoleDefinitionId
directoryScopeId = $Config.DirectoryScopeId
justification = $Config.Justification
scheduleInfo = @{
startDateTime = Get-Date
expiration = @{
type = "AfterDuration"
duration = $Config.Duration
$metadataPath = Join-Path -Path (Get-Location) -ChildPath "Metadata.json"

if (Test-Path -Path $metadataPath) {
Write-Host " Found Metadata.json. Using JSON body for request." -ForegroundColor DarkGray
$params = Get-Content -Raw -Path $metadataPath | ConvertFrom-Json -AsHashtable
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve PowerShell 5.1 compatibility when parsing Metadata.json

The new ConvertFrom-Json -AsHashtable call is only available in PowerShell Core (6+), but this script still declares support for "PowerShell 5.1+"; on Windows PowerShell 5.1, activating via Metadata.json will fail at parameter binding before the Graph request is sent. This creates a runtime regression specifically for 5.1 users whenever Metadata.json is present, so the JSON parsing path should avoid -AsHashtable (or gate it by PS version) to keep the documented compatibility.

Useful? React with 👍 / 👎.

}
else {
$params = @{
action = "selfActivate"
principalId = $principalId
roleDefinitionId = $Config.RoleDefinitionId
directoryScopeId = $Config.DirectoryScopeId
justification = $Config.Justification
scheduleInfo = @{
startDateTime = Get-Date
expiration = @{
type = "AfterDuration"
duration = $Config.Duration
}
}
ticketInfo = @{
ticketNumber = $Config.TicketNumber
ticketSystem = $Config.TicketSystem
}
}
ticketInfo = @{
ticketNumber = $Config.TicketNumber
ticketSystem = $Config.TicketSystem
}
}

Expand Down
Loading