TWL-KB-029 · PowerShell · IT / scripting

Access denied in a script

Identify which operation and resource were refused.

Applies to: Windows PowerShell and PowerShell 7.

Revision 5 · 18 November 2026 · General first-line guidance. Wording varies by version; a symptom is not a confirmed diagnosis.

Access is denied / UnauthorizedAccessException. Identify which operation and resource were refused.
Original explainer illustration, not a product screenshot. Select it to enlarge. All information is also in the text.

What does the message mean?

Some rows describe a visible symptom rather than an exact message. Wording marked “varies” may differ on your screen.

What you seeWhat it may indicateWhat to check
Access is denied / UnauthorizedAccessExceptionThe running identity may lack permission, or a policy may block the operation. Running as administrator is not a universal fix.Identify which operation and resource were refused.
No message at allProblems can happen without any message. A blank screen or a missing control is still useful evidence.Record the visible behaviour, the time and who is affected. Do not guess a code.
First checks: Identify the target; Check the identity; Ask the resource owner; Avoid automatic elevation
Original explainer illustration, not a product screenshot. Select it to enlarge. All information is also in the text.

Step-by-step checks

Work in order and stop when it is resolved. If your screen differs, note what is different and ask IT or the owner.

  1. Identify the target

    Do this
    Note the failed operation and resource, without exposing confidential paths.
    What you should see
    The denied action is known.
    Then what?
    If this explains what you see, record it and continue only if the next check still applies.
  2. Check the identity

    Do this
    Confirm which approved account or service identity should run the script.
    What you should see
    The running context matches or differs.
    Then what?
    Record the result without changing settings. Stop if work, data or security could be affected.
  3. Ask the resource owner

    Do this
    Ask the owner to verify the permission needed. Do not change permissions or share credentials.
    What you should see
    A permission need or policy block is identified.
    Then what?
    Use only the approved action described here. If it does not match your screen, stop and ask IT.
  4. Avoid automatic elevation

    Do this
    Ask IT to assess least-privilege access and partial results before another run.
    What you should see
    No unnecessary administrator run happens.
    Then what?
    If unresolved, contact IT or the owner with sanitised evidence. Do not repeat actions that could duplicate data.

When to stop and contact IT or the owner

What to put in your support request

The app and version if visible, your device, the time, the exact message, who is affected, and the checks you tried with what you saw. Remove names, addresses and confidential content from screenshots. Never send passwords or MFA codes.

Microsoft reference

Microsoft documentation for this topic (opens a new tab). Some links are product hubs. Official pages may include advanced steps; ask IT before applying them on a managed device.

Related guides

The Workflow Lab is independent of Microsoft and is not your employer’s service desk.