[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M699TV850F8131MBYN6BK54T":3,"skill-same:01M699TV850F8131MBYN6BK54T":84},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":46,"linkOnly":47,"markdownContent":48,"markdownBody":49,"frontMatter":50,"refName":55,"commitSha":56,"skillDirectory":57,"forksCount":58,"repositoryHtmlUrl":59,"repositoryHomepageUrl":60,"ownerHtmlUrl":61,"ownerBlogUrl":62,"ownerDescription":63,"updatedAt":64,"install":65,"resources":77},"01M699TV850F8131MBYN6BK54T","force-link-environment",null,"Force-links a development or target environment to a Power Platform Pipelines host, overriding any existing association with a previous host. Use when creating a deploymentenvironments record fails with \"this environment is already associated with another pipelines host\", or when intentionally migrating an environment from one host to another (e.g., Platform Host → Custom Host, or between two Custom Hosts). Calls the documented `ManageEnvironmentStamp` Dataverse action (the API behind the \"Force Link\" button in the Deployment Pipeline Configuration app). DESTRUCTIVE to the previous host: makers lose access to any pipelines in that host that used this environment. Reversible by running Force Link from the previous host. Use when asked to: \"force link environment\", \"force-link to new host\", \"switch pipelines host\", \"environment already associated with another host\", \"take over pipelines association\", \"relink environment to host\".","microsoft\u002Fpower-platform-skills","microsoft","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6154722?v=4","01M698VYDXZ6JW5WH3CRV650R8","Microsoft","01M699JVYJFB75D9JM70BN4H0Q",1149,"MIT","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fpower-pages\u002Fskills\u002Fforce-link-environment\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,9,45],"force link environment","link","environment","access","new","when","hosts","URL","host","app","power","fetch","confirmation","MCP","Bash","api","pipeline","search","learn","power platform","dataverse","docs","2026-11-10 10:12:30",false,"---\nname: force-link-environment\ndescription: >-\n  Force-links a development or target environment to a Power Platform Pipelines\n  host, overriding any existing association with a previous host. Use when\n  creating a deploymentenvironments record fails with \"this environment is\n  already associated with another pipelines host\", or when intentionally\n  migrating an environment from one host to another (e.g., Platform Host →\n  Custom Host, or between two Custom Hosts). Calls the documented\n  `ManageEnvironmentStamp` Dataverse action (the API behind the \"Force Link\"\n  button in the Deployment Pipeline Configuration app). DESTRUCTIVE to the\n  previous host: makers lose access to any pipelines in that host that used\n  this environment. Reversible by running Force Link from the previous host.\n  Use when asked to: \"force link environment\", \"force-link to new host\",\n  \"switch pipelines host\", \"environment already associated with another host\",\n  \"take over pipelines association\", \"relink environment to host\".\nuser-invocable: true\nargument-hint: \"Optional: '--host \u003Curl>' to skip the host resolution step; '--dev-env \u003CbapEnvId>' to skip the dev env prompt. With both flags supplied, the skill still pauses for destructive-action confirmation.\"\nallowed-tools: Read, Write, Edit, Bash, Glob, Grep, TaskCreate, TaskUpdate, TaskList, AskUserQuestion, mcp__plugin_power-pages_microsoft-learn__microsoft_docs_search, mcp__plugin_power-pages_microsoft-learn__microsoft_docs_fetch\nmodel: opus\n---\n\n> **Plugin check**: Run `node \"${PLUGIN_ROOT}\u002Fscripts\u002Fcheck-version.js\"` — if it outputs a message, show it to the user before proceeding.\n\n# force-link-environment\n\nMove a dev or target environment's Power Platform Pipelines host association from one host to another. This is the documented remediation when `deploymentenvironments` create fails with *\"this environment is already associated with another pipelines host\"*, and also the right tool when intentionally migrating environments between hosts.\n\n**Microsoft Learn (ground truth):** [Using Force Link to associate an environment with a new host](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fpower-platform\u002Falm\u002Fcustom-host-pipelines#using-force-link-to-associate-an-environment-with-a-new-host)\n\n## What this skill changes\n\nIn the **target host** (the new host the user wants to use):\n- Marks the existing `deploymentenvironments` record as the active stamp for the BAP environment.\n- Re-runs validation; on success, `validationstatus` flips to `Succeeded` (200000001).\n\nIn the **previous host** (the host the env was previously linked to):\n- The corresponding `deploymentenvironments` row is **delinked**. Its `validationstatus` is left stale until refreshed in the previous host's UI.\n- Makers who could run pipelines through that environment in the previous host **lose access** to those pipelines via this environment.\n\nThe action is reversible by running Force Link again from the previous host.\n\n## Phase 1.5 — Microsoft Learn grounding (required)\n\nBefore any Dataverse call, refresh the agent's grounding by fetching the doc above via `mcp__plugin_power-pages_microsoft-learn__microsoft_docs_fetch`. If the doc has updated behaviors (e.g., new permission requirements, new warning text), surface them to the user before continuing. See `${PLUGIN_ROOT}\u002Freferences\u002Falm-docs-grounding.md` for the shared pattern.\n\n## Phases\n\n| # | Phase | Output |\n|---|---|---|\n| 1 | Prerequisites | Azure CLI token for the host environment; PAC CLI authenticated |\n| 1.5 | MCP Learn grounding | Confirmed current behavior of Force Link \u002F `ManageEnvironmentStamp` |\n| 2 | Identify host + dev env | `hostEnvUrl`, target host's `deploymentEnvironmentId`, source BAP env GUID |\n| 3 | Resolve `deploymentenvironments` record | Either an existing record on the new host, or a freshly created one |\n| 4 | Confirm destructive action | Explicit user consent via `AskUserQuestion` |\n| 5 | Execute Force Link | 204 from `ManageEnvironmentStamp` + post-validation Succeeded |\n| 6 | Write marker + summary | `docs\u002Falm\u002Flast-force-link.json` + human-readable summary |\n\nCreate all tasks at Phase 1 start with `TaskCreate`. Mark each `in_progress` when starting and `completed` when done.\n\n---\n\n## Phase 1 — Prerequisites\n\nReuse the shared verifier:\n\n```bash\nnode \"${PLUGIN_ROOT}\u002Fscripts\u002Flib\u002Fverify-alm-prerequisites.js\"\n```\n\nSpecifically required:\n- **PAC CLI auth** — `pac env who` must report an authenticated environment (for `--dev-env` auto-discovery).\n- **Azure CLI auth** — `az account show` succeeds.\n- **Host-scoped token** — the caller must have Deployment Pipeline Administrator on the target host (the host the env is being linked TO). Without it, `ManageEnvironmentStamp` returns 403.\n\nFetch the host token from Azure CLI using the host's Dataverse URL as the resource. Reuse `getAuthToken` from `scripts\u002Flib\u002Fvalidation-helpers.js`.\n\n## Phase 1.5 — MCP Learn grounding\n\nCall:\n\n```\nmcp__plugin_power-pages_microsoft-learn__microsoft_docs_fetch(url=\n  \"https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fpower-platform\u002Falm\u002Fcustom-host-pipelines\")\n```\n\nConfirm the *\"Using Force Link…\"* section's current warnings before proceeding. If the section now mentions new prerequisites or rollback constraints not covered in this skill, surface them to the user.\n\n## Phase 2 — Identify host + dev env\n\n\u003C!-- gate: force-link-environment:2.host-url | category=plan | cancel-leaves=nothing -->\n\n> ? **Gate (plan · force-link-environment:2.host-url):** Pick the target host environment URL when arg \u002F marker resolution paths all came up empty. Fires only on the \"no `--host` arg, no `last-host-check.json`, no `last-pipeline.json`\" branch (step 4 below).\n>\n> **Trigger:** Phase 2 resolution order steps 1–3 all returned no value.\n> **Why we ask:** Auto-picking the wrong host runs `ManageEnvironmentStamp` against the wrong tenant and moves the stamp irreversibly without consent.\n> **Cancel leaves:** Nothing — no API call yet.\n\n\u003C!-- gate: force-link-environment:2.dev-env | category=plan | cancel-leaves=nothing -->\n\n> ? **Gate (plan · force-link-environment:2.dev-env):** Pick (or paste) the source dev env's BAP env GUID when `--dev-env` arg is absent and `pac env who` didn't confirm. Fires only on the \"no arg + no confirmation\" branch (step 3 below).\n>\n> **Trigger:** Phase 2 BAP-GUID resolution steps 1–2 all returned no value.\n> **Why we ask:** Auto-picking the wrong dev env relinks a different env to the new host — makers of the wrong env lose pipeline access.\n> **Cancel leaves:** Nothing — no API call yet.\n\nResolution order for `hostEnvUrl`:\n1. `--host \u003Curl>` argument, if supplied.\n2. `docs\u002Falm\u002Flast-host-check.json` (written by `ensure-pipelines-host`) — read `finalHostEnvUrl`.\n3. `docs\u002Falm\u002Flast-pipeline.json` — read `hostEnvUrl`.\n4. Prompt user via `AskUserQuestion`.\n\nResolution order for the source dev env's BAP env GUID:\n1. `--dev-env \u003Cguid>` argument, if supplied.\n2. `pac env who` (current PAC CLI env) — but ONLY if the user confirms this is the env to relink.\n3. Prompt user via `AskUserQuestion`.\n\n## Phase 3 — Resolve `deploymentenvironments` record on the new host\n\n**Goal of this phase:** obtain the `deploymentEnvironmentId` (the new host's record ID) regardless of whether it already exists, just got created, or got created in a Failed state. Force Link in Phase 5 cannot run without that GUID.\n\n### Step 3.1 — Look up by BAP env GUID\n\n```bash\nGET {hostEnvUrl}\u002Fapi\u002Fdata\u002Fv9.1\u002Fdeploymentenvironments?$filter=environmentid eq '{bapEnvId}'&$select=deploymentenvironmentid,name,environmenttype,validationstatus,errormessage\n```\n\n| Result | Action |\n|---|---|\n| One hit, `validationstatus = 200000001` (Succeeded) | Already linked to this host. Skip to Phase 6 with a no-op summary; no Force Link needed. |\n| One hit, `validationstatus = 200000002` (Failed) | This is the *\"already associated with another pipelines host\"* state. Capture `deploymentenvironmentid` + `errormessage`. Skip to Phase 4 with those values. |\n| One hit, `validationstatus = 200000000` (Pending) | Wait briefly (3–5 s) and re-query. If still Pending after ~20 s, abort with a \"validation still in progress; retry later\" message. |\n| Zero hits | Continue to Step 3.2 — the record needs to be created first. |\n\n### Step 3.2 — Create the record on the new host (when Step 3.1 returned zero hits)\n\n```bash\nnode \"${PLUGIN_ROOT}\u002Fscripts\u002Flib\u002Fcreate-deployment-environment.js\" \\\n  --hostEnvUrl \u003ChostEnvUrl> \\\n  --token \u003ChostToken> \\\n  --name \"\u003Cdisplay name>\" \\\n  --bapEnvId \u003CbapEnvId> \\\n  --environmentType \u003C200000000|200000001>\n```\n\nThe helper polls `validationstatus` and **throws on Failed** without returning the new record's GUID in the error payload. Three outcomes to handle:\n\n| Helper outcome | Action |\n|---|---|\n| Resolves with `validationStatus = Succeeded` | Record is fully linked. Skip to Phase 6 — no Force Link needed. |\n| Throws with message containing *\"already associated with another pipelines host\"* (or similar host-claim wording) | The record **was** created in Failed state but the helper's error doesn't surface the new GUID. **Re-run Step 3.1's GET to recover the just-created record's `deploymentenvironmentid`**, then proceed to Phase 4 with that ID + the captured errormessage. Do NOT retry the create — it would log a duplicate `name`. |\n| Throws with any other message | Surface the error verbatim and abort. Force Link is not the right tool — this is a different failure (e.g., 403 on create = caller lacks role on host; 400 = bad `bapEnvId`). |\n\n**Why the re-query is necessary:** `create-deployment-environment.js` is idempotent on subsequent calls (it short-circuits via `findExistingByBapId`), but on the *first* call that lands in Failed validation it raises before the return path runs. Re-querying by `environmentid eq '{bapEnvId}'` is the canonical recovery — the same query Step 3.1 already uses.\n\nAfter this phase ends, you must hold a non-null `deploymentEnvironmentId`. If you don't, abort Phase 4 with a clear \"could not resolve record on new host\" message.\n\n## Phase 4 — Confirm destructive action\n\n\u003C!-- gate: force-link-environment:4.destructive | category=consent | cancel-leaves=nothing -->\n> ? **Gate (consent · force-link-environment:4.destructive):** Mandatory consent before `ManageEnvironmentStamp` cross-host stamp move. Previous host loses pipeline access for this env. Reversible only by re-running Force Link from the previous host. **Fires fresh on every skill invocation.** Each invocation force-links exactly one env to one host. If a maker needs to migrate multiple envs across hosts, they invoke this skill once per env — each invocation requires its own consent prompt with its own env identity echoed back. No `--yes` flag, no batch mode, no consent carry-over.\n\nThis is the **mandatory** gate. Use `AskUserQuestion` with both options and a clear destructive-action warning in the question text. Required fields to display before asking:\n\n- Target host (the new host)\n- Source environment name + BAP env GUID\n- The error message from the previous host's stamp (from Phase 3), if any\n- Documented side effects:\n  - \"Makers in the previous host lose pipeline access for this environment\"\n  - \"The previous host's environment record is left with a stale validation status\"\n  - \"Reversible by running Force Link from the previous host\"\n\nQuestion structure:\n\n```\nquestion: \"Force-link this environment to \u003Chost name>? This will remove its association with the previous host.\"\noptions:\n  - \"Yes — force link\" (Recommended only if user is intentionally migrating)\n  - \"Cancel\"\n```\n\nIf the user picks Cancel, exit cleanly (no marker file written) and recommend `\u002Fpower-pages:ensure-pipelines-host detect-only` for further diagnosis.\n\n## Phase 5 — Execute Force Link\n\n```bash\nnode \"${PLUGIN_ROOT}\u002Fscripts\u002Flib\u002Fforce-link-environment.js\" \\\n  --hostEnvUrl \u003ChostEnvUrl> \\\n  --token \u003ChostToken> \\\n  --deploymentEnvironmentId \u003Cguid>\n```\n\nThe helper:\n1. Calls `ManageEnvironmentStamp` (returns 204 No Content on success).\n2. Re-polls `validationstatus` on the same record every 3s up to 20 attempts.\n3. Resolves on Succeeded (200000001), throws on Failed (200000002) with the captured `errormessage`.\n\nIf the helper throws with status 403, the caller lacks Deployment Pipeline Administrator on the target host — surface that as the remediation message.\n\nIf the helper throws with status 404, the `deploymentenvironments` record doesn't exist on the target host — Phase 3 must have failed silently; loop back.\n\n## Phase 6 — Write marker + summary\n\nEnsure the `docs\u002Falm\u002F` directory exists (`node -e \"require('fs').mkdirSync('docs\u002Falm',{recursive:true})\"`), then write `docs\u002Falm\u002Flast-force-link.json`:\n\n```json\n{\n  \"schemaVersion\": 1,\n  \"hostEnvUrl\": \"https:\u002F\u002F...\",\n  \"deploymentEnvironmentId\": \"...\",\n  \"bapEnvId\": \"...\",\n  \"previousHostEnvUrl\": \"https:\u002F\u002F...\",\n  \"validationStatus\": 200000001,\n  \"forcedAt\": \"2026-05-11T...\"\n}\n```\n\n`previousHostEnvUrl` is best-effort. Derive in this order; leave `null` if none of these yield a value:\n1. **From `docs\u002Falm\u002Flast-host-check.json`** (written by `ensure-pipelines-host`): if `finalHostEnvUrl` is set AND differs from the current `hostEnvUrl`, the discovery flow had already bound this env to that previous host — record it.\n2. **From Phase 3's errormessage**: scan the captured `errormessage` for the pattern `https?:\u002F\u002F[^\\s'\"]+\\.(crm\\d*\\.dynamics\\.com|dynamics-int\\.com|crm\\.microsoftdynamics\\.us)` and pick the first match that is **not** the current `hostEnvUrl`. Microsoft's error wording on the \"already associated\" path sometimes includes the prior host's URL, sometimes only its display name; treat the regex as opportunistic, not authoritative.\n3. **Otherwise**: leave `null`. The marker schema permits this — validator does not require the field.\n\nDo NOT prompt the user to fill `previousHostEnvUrl`; it's informational only for the post-run summary.\n\nPresent a summary table with:\n- Environment force-linked\n- Old host → new host\n- Validation status\n- Reminder: \"You can undo this by running `\u002Fpower-pages:force-link-environment` from the previous host.\"\n\nRecord skill usage per `${PLUGIN_ROOT}\u002Freferences\u002Fskill-tracking-reference.md`.\n\n---\n\n## Failure modes & remediation\n\n| Failure | Surface to user | Next step |\n|---|---|---|\n| `403 Forbidden` on `ManageEnvironmentStamp` | \"You need Deployment Pipeline Administrator role on \u003ChostName>.\" | Ask host admin to grant the role; documented in [share with pipeline administrators](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fpower-platform\u002Falm\u002Fcustom-host-pipelines#share-with-pipeline-administrators). |\n| `404 Not Found` on the deployment env record | \"No deploymentenvironments record exists yet on this host.\" | Re-run Phase 3's create step. |\n| Post-link validation status flips to Failed | Show the `errormessage` verbatim. | If the message mentions the env is still associated with a host, the previous host may have an immediate-reapply policy — check with the previous host's admin. |\n| User cancels at Phase 4 | \"Force Link not performed; previous association preserved.\" | Suggest `\u002Fpower-pages:ensure-pipelines-host detect-only` for a wider diagnosis. |\n\n## What this skill does NOT do\n\n- It does not install the Pipelines application on the new host — use `\u002Fpower-pages:ensure-pipelines-host` for that.\n- It does not create the new host environment itself.\n- It does not re-link pipeline definitions; only the env↔host stamp is moved. Pipelines that referenced this env in the previous host stay there and lose this env as a participant.\n- It does not modify the user's solution. No `.solution-manifest.json` updates; no `AddSolutionComponent` calls.\n\n## Progress tracking\n\n| Phase | Status |\n|---|---|\n| 1 — Prerequisites | ⏳ |\n| 1.5 — MCP Learn grounding | ⏳ |\n| 2 — Identify host + dev env | ⏳ |\n| 3 — Resolve deploymentenvironments record | ⏳ |\n| 4 — Confirm destructive action | ⏳ |\n| 5 — Execute Force Link | ⏳ |\n| 6 — Write marker + summary | ⏳ |\n\nUpdate this table as phases complete.\n","> **Plugin check**: Run `node \"${PLUGIN_ROOT}\u002Fscripts\u002Fcheck-version.js\"` — if it outputs a message, show it to the user before proceeding.\n\n# force-link-environment\n\nMove a dev or target environment's Power Platform Pipelines host association from one host to another. This is the documented remediation when `deploymentenvironments` create fails with *\"this environment is already associated with another pipelines host\"*, and also the right tool when intentionally migrating environments between hosts.\n\n**Microsoft Learn (ground truth):** [Using Force Link to associate an environment with a new host](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fpower-platform\u002Falm\u002Fcustom-host-pipelines#using-force-link-to-associate-an-environment-with-a-new-host)\n\n## What this skill changes\n\nIn the **target host** (the new host the user wants to use):\n- Marks the existing `deploymentenvironments` record as the active stamp for the BAP environment.\n- Re-runs validation; on success, `validationstatus` flips to `Succeeded` (200000001).\n\nIn the **previous host** (the host the env was previously linked to):\n- The corresponding `deploymentenvironments` row is **delinked**. Its `validationstatus` is left stale until refreshed in the previous host's UI.\n- Makers who could run pipelines through that environment in the previous host **lose access** to those pipelines via this environment.\n\nThe action is reversible by running Force Link again from the previous host.\n\n## Phase 1.5 — Microsoft Learn grounding (required)\n\nBefore any Dataverse call, refresh the agent's grounding by fetching the doc above via `mcp__plugin_power-pages_microsoft-learn__microsoft_docs_fetch`. If the doc has updated behaviors (e.g., new permission requirements, new warning text), surface them to the user before continuing. See `${PLUGIN_ROOT}\u002Freferences\u002Falm-docs-grounding.md` for the shared pattern.\n\n## Phases\n\n| # | Phase | Output |\n|---|---|---|\n| 1 | Prerequisites | Azure CLI token for the host environment; PAC CLI authenticated |\n| 1.5 | MCP Learn grounding | Confirmed current behavior of Force Link \u002F `ManageEnvironmentStamp` |\n| 2 | Identify host + dev env | `hostEnvUrl`, target host's `deploymentEnvironmentId`, source BAP env GUID |\n| 3 | Resolve `deploymentenvironments` record | Either an existing record on the new host, or a freshly created one |\n| 4 | Confirm destructive action | Explicit user consent via `AskUserQuestion` |\n| 5 | Execute Force Link | 204 from `ManageEnvironmentStamp` + post-validation Succeeded |\n| 6 | Write marker + summary | `docs\u002Falm\u002Flast-force-link.json` + human-readable summary |\n\nCreate all tasks at Phase 1 start with `TaskCreate`. Mark each `in_progress` when starting and `completed` when done.\n\n---\n\n## Phase 1 — Prerequisites\n\nReuse the shared verifier:\n\n```bash\nnode \"${PLUGIN_ROOT}\u002Fscripts\u002Flib\u002Fverify-alm-prerequisites.js\"\n```\n\nSpecifically required:\n- **PAC CLI auth** — `pac env who` must report an authenticated environment (for `--dev-env` auto-discovery).\n- **Azure CLI auth** — `az account show` succeeds.\n- **Host-scoped token** — the caller must have Deployment Pipeline Administrator on the target host (the host the env is being linked TO). Without it, `ManageEnvironmentStamp` returns 403.\n\nFetch the host token from Azure CLI using the host's Dataverse URL as the resource. Reuse `getAuthToken` from `scripts\u002Flib\u002Fvalidation-helpers.js`.\n\n## Phase 1.5 — MCP Learn grounding\n\nCall:\n\n```\nmcp__plugin_power-pages_microsoft-learn__microsoft_docs_fetch(url=\n  \"https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fpower-platform\u002Falm\u002Fcustom-host-pipelines\")\n```\n\nConfirm the *\"Using Force Link…\"* section's current warnings before proceeding. If the section now mentions new prerequisites or rollback constraints not covered in this skill, surface them to the user.\n\n## Phase 2 — Identify host + dev env\n\n\u003C!-- gate: force-link-environment:2.host-url | category=plan | cancel-leaves=nothing -->\n\n> ? **Gate (plan · force-link-environment:2.host-url):** Pick the target host environment URL when arg \u002F marker resolution paths all came up empty. Fires only on the \"no `--host` arg, no `last-host-check.json`, no `last-pipeline.json`\" branch (step 4 below).\n>\n> **Trigger:** Phase 2 resolution order steps 1–3 all returned no value.\n> **Why we ask:** Auto-picking the wrong host runs `ManageEnvironmentStamp` against the wrong tenant and moves the stamp irreversibly without consent.\n> **Cancel leaves:** Nothing — no API call yet.\n\n\u003C!-- gate: force-link-environment:2.dev-env | category=plan | cancel-leaves=nothing -->\n\n> ? **Gate (plan · force-link-environment:2.dev-env):** Pick (or paste) the source dev env's BAP env GUID when `--dev-env` arg is absent and `pac env who` didn't confirm. Fires only on the \"no arg + no confirmation\" branch (step 3 below).\n>\n> **Trigger:** Phase 2 BAP-GUID resolution steps 1–2 all returned no value.\n> **Why we ask:** Auto-picking the wrong dev env relinks a different env to the new host — makers of the wrong env lose pipeline access.\n> **Cancel leaves:** Nothing — no API call yet.\n\nResolution order for `hostEnvUrl`:\n1. `--host \u003Curl>` argument, if supplied.\n2. `docs\u002Falm\u002Flast-host-check.json` (written by `ensure-pipelines-host`) — read `finalHostEnvUrl`.\n3. `docs\u002Falm\u002Flast-pipeline.json` — read `hostEnvUrl`.\n4. Prompt user via `AskUserQuestion`.\n\nResolution order for the source dev env's BAP env GUID:\n1. `--dev-env \u003Cguid>` argument, if supplied.\n2. `pac env who` (current PAC CLI env) — but ONLY if the user confirms this is the env to relink.\n3. Prompt user via `AskUserQuestion`.\n\n## Phase 3 — Resolve `deploymentenvironments` record on the new host\n\n**Goal of this phase:** obtain the `deploymentEnvironmentId` (the new host's record ID) regardless of whether it already exists, just got created, or got created in a Failed state. Force Link in Phase 5 cannot run without that GUID.\n\n### Step 3.1 — Look up by BAP env GUID\n\n```bash\nGET {hostEnvUrl}\u002Fapi\u002Fdata\u002Fv9.1\u002Fdeploymentenvironments?$filter=environmentid eq '{bapEnvId}'&$select=deploymentenvironmentid,name,environmenttype,validationstatus,errormessage\n```\n\n| Result | Action |\n|---|---|\n| One hit, `validationstatus = 200000001` (Succeeded) | Already linked to this host. Skip to Phase 6 with a no-op summary; no Force Link needed. |\n| One hit, `validationstatus = 200000002` (Failed) | This is the *\"already associated with another pipelines host\"* state. Capture `deploymentenvironmentid` + `errormessage`. Skip to Phase 4 with those values. |\n| One hit, `validationstatus = 200000000` (Pending) | Wait briefly (3–5 s) and re-query. If still Pending after ~20 s, abort with a \"validation still in progress; retry later\" message. |\n| Zero hits | Continue to Step 3.2 — the record needs to be created first. |\n\n### Step 3.2 — Create the record on the new host (when Step 3.1 returned zero hits)\n\n```bash\nnode \"${PLUGIN_ROOT}\u002Fscripts\u002Flib\u002Fcreate-deployment-environment.js\" \\\n  --hostEnvUrl \u003ChostEnvUrl> \\\n  --token \u003ChostToken> \\\n  --name \"\u003Cdisplay name>\" \\\n  --bapEnvId \u003CbapEnvId> \\\n  --environmentType \u003C200000000|200000001>\n```\n\nThe helper polls `validationstatus` and **throws on Failed** without returning the new record's GUID in the error payload. Three outcomes to handle:\n\n| Helper outcome | Action |\n|---|---|\n| Resolves with `validationStatus = Succeeded` | Record is fully linked. Skip to Phase 6 — no Force Link needed. |\n| Throws with message containing *\"already associated with another pipelines host\"* (or similar host-claim wording) | The record **was** created in Failed state but the helper's error doesn't surface the new GUID. **Re-run Step 3.1's GET to recover the just-created record's `deploymentenvironmentid`**, then proceed to Phase 4 with that ID + the captured errormessage. Do NOT retry the create — it would log a duplicate `name`. |\n| Throws with any other message | Surface the error verbatim and abort. Force Link is not the right tool — this is a different failure (e.g., 403 on create = caller lacks role on host; 400 = bad `bapEnvId`). |\n\n**Why the re-query is necessary:** `create-deployment-environment.js` is idempotent on subsequent calls (it short-circuits via `findExistingByBapId`), but on the *first* call that lands in Failed validation it raises before the return path runs. Re-querying by `environmentid eq '{bapEnvId}'` is the canonical recovery — the same query Step 3.1 already uses.\n\nAfter this phase ends, you must hold a non-null `deploymentEnvironmentId`. If you don't, abort Phase 4 with a clear \"could not resolve record on new host\" message.\n\n## Phase 4 — Confirm destructive action\n\n\u003C!-- gate: force-link-environment:4.destructive | category=consent | cancel-leaves=nothing -->\n> ? **Gate (consent · force-link-environment:4.destructive):** Mandatory consent before `ManageEnvironmentStamp` cross-host stamp move. Previous host loses pipeline access for this env. Reversible only by re-running Force Link from the previous host. **Fires fresh on every skill invocation.** Each invocation force-links exactly one env to one host. If a maker needs to migrate multiple envs across hosts, they invoke this skill once per env — each invocation requires its own consent prompt with its own env identity echoed back. No `--yes` flag, no batch mode, no consent carry-over.\n\nThis is the **mandatory** gate. Use `AskUserQuestion` with both options and a clear destructive-action warning in the question text. Required fields to display before asking:\n\n- Target host (the new host)\n- Source environment name + BAP env GUID\n- The error message from the previous host's stamp (from Phase 3), if any\n- Documented side effects:\n  - \"Makers in the previous host lose pipeline access for this environment\"\n  - \"The previous host's environment record is left with a stale validation status\"\n  - \"Reversible by running Force Link from the previous host\"\n\nQuestion structure:\n\n```\nquestion: \"Force-link this environment to \u003Chost name>? This will remove its association with the previous host.\"\noptions:\n  - \"Yes — force link\" (Recommended only if user is intentionally migrating)\n  - \"Cancel\"\n```\n\nIf the user picks Cancel, exit cleanly (no marker file written) and recommend `\u002Fpower-pages:ensure-pipelines-host detect-only` for further diagnosis.\n\n## Phase 5 — Execute Force Link\n\n```bash\nnode \"${PLUGIN_ROOT}\u002Fscripts\u002Flib\u002Fforce-link-environment.js\" \\\n  --hostEnvUrl \u003ChostEnvUrl> \\\n  --token \u003ChostToken> \\\n  --deploymentEnvironmentId \u003Cguid>\n```\n\nThe helper:\n1. Calls `ManageEnvironmentStamp` (returns 204 No Content on success).\n2. Re-polls `validationstatus` on the same record every 3s up to 20 attempts.\n3. Resolves on Succeeded (200000001), throws on Failed (200000002) with the captured `errormessage`.\n\nIf the helper throws with status 403, the caller lacks Deployment Pipeline Administrator on the target host — surface that as the remediation message.\n\nIf the helper throws with status 404, the `deploymentenvironments` record doesn't exist on the target host — Phase 3 must have failed silently; loop back.\n\n## Phase 6 — Write marker + summary\n\nEnsure the `docs\u002Falm\u002F` directory exists (`node -e \"require('fs').mkdirSync('docs\u002Falm',{recursive:true})\"`), then write `docs\u002Falm\u002Flast-force-link.json`:\n\n```json\n{\n  \"schemaVersion\": 1,\n  \"hostEnvUrl\": \"https:\u002F\u002F...\",\n  \"deploymentEnvironmentId\": \"...\",\n  \"bapEnvId\": \"...\",\n  \"previousHostEnvUrl\": \"https:\u002F\u002F...\",\n  \"validationStatus\": 200000001,\n  \"forcedAt\": \"2026-05-11T...\"\n}\n```\n\n`previousHostEnvUrl` is best-effort. Derive in this order; leave `null` if none of these yield a value:\n1. **From `docs\u002Falm\u002Flast-host-check.json`** (written by `ensure-pipelines-host`): if `finalHostEnvUrl` is set AND differs from the current `hostEnvUrl`, the discovery flow had already bound this env to that previous host — record it.\n2. **From Phase 3's errormessage**: scan the captured `errormessage` for the pattern `https?:\u002F\u002F[^\\s'\"]+\\.(crm\\d*\\.dynamics\\.com|dynamics-int\\.com|crm\\.microsoftdynamics\\.us)` and pick the first match that is **not** the current `hostEnvUrl`. Microsoft's error wording on the \"already associated\" path sometimes includes the prior host's URL, sometimes only its display name; treat the regex as opportunistic, not authoritative.\n3. **Otherwise**: leave `null`. The marker schema permits this — validator does not require the field.\n\nDo NOT prompt the user to fill `previousHostEnvUrl`; it's informational only for the post-run summary.\n\nPresent a summary table with:\n- Environment force-linked\n- Old host → new host\n- Validation status\n- Reminder: \"You can undo this by running `\u002Fpower-pages:force-link-environment` from the previous host.\"\n\nRecord skill usage per `${PLUGIN_ROOT}\u002Freferences\u002Fskill-tracking-reference.md`.\n\n---\n\n## Failure modes & remediation\n\n| Failure | Surface to user | Next step |\n|---|---|---|\n| `403 Forbidden` on `ManageEnvironmentStamp` | \"You need Deployment Pipeline Administrator role on \u003ChostName>.\" | Ask host admin to grant the role; documented in [share with pipeline administrators](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fpower-platform\u002Falm\u002Fcustom-host-pipelines#share-with-pipeline-administrators). |\n| `404 Not Found` on the deployment env record | \"No deploymentenvironments record exists yet on this host.\" | Re-run Phase 3's create step. |\n| Post-link validation status flips to Failed | Show the `errormessage` verbatim. | If the message mentions the env is still associated with a host, the previous host may have an immediate-reapply policy — check with the previous host's admin. |\n| User cancels at Phase 4 | \"Force Link not performed; previous association preserved.\" | Suggest `\u002Fpower-pages:ensure-pipelines-host detect-only` for a wider diagnosis. |\n\n## What this skill does NOT do\n\n- It does not install the Pipelines application on the new host — use `\u002Fpower-pages:ensure-pipelines-host` for that.\n- It does not create the new host environment itself.\n- It does not re-link pipeline definitions; only the env↔host stamp is moved. Pipelines that referenced this env in the previous host stay there and lose this env as a participant.\n- It does not modify the user's solution. No `.solution-manifest.json` updates; no `AddSolutionComponent` calls.\n\n## Progress tracking\n\n| Phase | Status |\n|---|---|\n| 1 — Prerequisites | ⏳ |\n| 1.5 — MCP Learn grounding | ⏳ |\n| 2 — Identify host + dev env | ⏳ |\n| 3 — Resolve deploymentenvironments record | ⏳ |\n| 4 — Confirm destructive action | ⏳ |\n| 5 — Execute Force Link | ⏳ |\n| 6 — Write marker + summary | ⏳ |\n\nUpdate this table as phases complete.\n",{"name":5,"model":51,"description":7,"allowed-tools":52,"argument-hint":53,"user-invocable":54},"opus","Read, Write, Edit, Bash, Glob, Grep, TaskCreate, TaskUpdate, TaskList, AskUserQuestion, mcp__plugin_power-pages_microsoft-learn__microsoft_docs_search, mcp__plugin_power-pages_microsoft-learn__microsoft_docs_fetch","Optional: '--host \u003Curl>' to skip the host resolution step; '--dev-env \u003CbapEnvId>' to skip the dev env prompt. With both flags supplied, the skill still pauses for destructive-action confirmation.",true,"main","0a55a88fa2855404029d1e5450faf92878baf763","plugins\u002Fpower-pages\u002Fskills\u002Fforce-link-environment",232,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills","https:\u002F\u002Fmicrosoft.github.io\u002Fpower-platform-skills\u002F","https:\u002F\u002Fgithub.com\u002Fmicrosoft","https:\u002F\u002Fopensource.microsoft.com","Open source projects and samples from Microsoft","2026-11-14 21:46:39",{"source":8,"skillName":5,"commands":66,"prompt":76,"zipAvailable":54},[67,70,73],{"tool":68,"command":69},"npx","npx skills add microsoft\u002Fpower-platform-skills --skill force-link-environment",{"tool":71,"command":72},"bunx","bunx skills add microsoft\u002Fpower-platform-skills --skill force-link-environment",{"tool":74,"command":75},"pnpm","pnpm dlx skills add microsoft\u002Fpower-platform-skills --skill force-link-environment","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fpower-pages\u002Fskills\u002Fforce-link-environment\u002FSKILL.md",[78],{"path":79,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":82,"sourceHtmlUrl":83},"scripts\u002Fvalidate-force-link.js","SCRIPT","脚本",2818,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fpower-pages\u002Fskills\u002Fforce-link-environment\u002Fscripts\u002Fvalidate-force-link.js",[85,93,112,135,153,167],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":92},"01M78JN2BFRRV1J54Q6WKZQ08D","compare-site-configurations","Compare Power Pages site configurations between two environments, such as dev, test and production, or between a local download and the live site, and explain which differences change site behavior. Use when a site works in one environment but not another (for example, works in dev but fails in test), to check configuration drift before promoting or deploying, or to see what changed between two sites. Produces a shareable HTML report and a JSON file that VS Code can import.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fpower-pages\u002Fskills\u002Fcompare-site-configurations\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":46},"01M699WVHX0XN59EPBTTPEKYPG","setup","Use when Process Intelligence needs building, explicit cloud\u002Faccount\u002Fenvironment configuration, sign-in, connection diagnostics, or recovery from an authentication error.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprocess-intelligence\u002Fskills\u002Fsetup\u002FSKILL.md",[],[95,100,101,102,26,103,29,104,105,106,38,107,108,109,110,111],"configuration","diagnostics","error","cloud","connection","authentication","use","recovery","process","sign","read","intelligence",{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":123,"publishedAt":46},"01M699WSR9EX55YY1WD9J22FEG","report-issue","Use when the user wants a Process Intelligence bug-report draft or support summary for a failed operation.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprocess-intelligence\u002Fskills\u002Freport-issue\u002FSKILL.md",[118],{"categoryNo":119,"categoryName":120,"taxonomyType":121,"taxonomyTypeDesc":122},"01JBSEEDCAT000000000000034","行政与办公人员","PROFESSION","适用职业",[124,125,126,127,106,29,128,129,108,130,111,131,132,133,134],"issue","report","report issue","bug-report","operation","draft","bug","summary","user","for","support",{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":139,"categories":140,"keywords":141,"publishedAt":46},"01M699WR26YQ9Q21KE6MJF5B2G","investigate-process","Use when a broad Process Mining business question, observed pattern or competing explanation needs investigation across analytical perspectives.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprocess-intelligence\u002Fskills\u002Finvestigate-process\u002FSKILL.md",[],[142,108,143,144,106,145,146,29,147,148,149,110,150,151,152],"investigate","investigate process","question","process mining","business","across","perspectives","mining","pattern","investigation","analytical",{"skillNo":154,"name":155,"nameZh":6,"description":156,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":157,"categories":158,"keywords":159,"publishedAt":46},"01M699WP9SDG5ZR12P8VYNXKTN","derive-metric","Use when a requested measure is missing, a saved custom metric needs reuse, or an ephemeral formula or derived scalar is needed.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprocess-intelligence\u002Fskills\u002Fderive-metric\u002FSKILL.md",[],[160,161,162,163,164,165,106,29,166,110],"metric","derive metric","missing","formula","custom","reuse","saved",{"skillNo":168,"name":169,"nameZh":6,"description":170,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":171,"categories":172,"keywords":173,"publishedAt":46},"01M699WMG5R8P6SMTDAS1TKF9E","compare-cohorts","Use when comparing process cohorts, departments, periods or before-and-after results under matched definitions.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprocess-intelligence\u002Fskills\u002Fcompare-cohorts\u002FSKILL.md",[],[174,175,106,29,176,108,110],"compare","compare cohorts","results"]