Skip to content

Support Metadata.json body for PIM activation request#5

Open
akhilsmokie3-ops wants to merge 1 commit into
masterfrom
codex/use-solidity-metadata.json-output-file
Open

Support Metadata.json body for PIM activation request#5
akhilsmokie3-ops wants to merge 1 commit into
masterfrom
codex/use-solidity-metadata.json-output-file

Conversation

@akhilsmokie3-ops
Copy link
Copy Markdown
Owner

Motivation

  • Allow external tooling or CI to supply the full PIM activation request body via a JSON file so the script can be driven from files instead of only in-script values.
  • Make it easy to test and reproduce activation payloads by providing a sample Metadata.json payload structure that the script can consume.

Description

  • Updated entra-pim-self-activate.ps1 to check the current working directory for Metadata.json and, when present, load it using Get-Content -Raw | ConvertFrom-Json -AsHashtable and use it as the -BodyParameter for New-MgRoleManagementDirectoryRoleAssignmentScheduleRequest.
  • Preserved the original inline hashtable construction as a fallback when Metadata.json is not found so existing usage remains unchanged.
  • Added a sample Metadata.json file that demonstrates the expected request payload fields (action, principalId, roleDefinitionId, directoryScopeId, scheduleInfo, and ticketInfo).

Testing

  • Validated that Metadata.json is valid JSON using python -m json.tool Metadata.json, which returned success.
  • Verified the updated script contains the new Metadata.json detection and parsing logic by searching code patterns with rg and inspecting the modified region with nl/sed, both showing the new conditional branch.
  • Confirmed that when present the parsed JSON is assigned to the params variable which is then passed to New-MgRoleManagementDirectoryRoleAssignmentScheduleRequest -BodyParameter, by reviewing the runtime insertion point in the script.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 55fb519f43

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant