Share via

Invalid JWT access token

Lewis Venables 0 Reputation points
2025-09-04T11:31:00.41+00:00

Hi,

Im trying to setup azure automation to disable and enable a conditional access policy via a runbook, ive installed the two specific modules from powershell gallery, Microsoft.Graph.Authentication & Microsoft.Graph.Identity.SignIns both version 2.30.0, ive read online that I will get the access token error with this version so downgrade to 2.25.0 by manually uploading the modules. I have done this and then i get the error that Update-MgIdentityConditionalAccessPolicy cmdlet isnt a recognised cmdlet, is there a correct way of uploading the modules from a zip.

Please see below script i am trying

#Load required modules

Import-Module Microsoft.Graph.Authentication

Import-Module Microsoft.Graph.Identity.SignIns

Connect to Graph with Managed Identity

Connect-MgGraph -Identity -NoWelcome

Use the policy ID (replace with yours from Get-MgConditionalAccessPolicy)

$policyId = "my policy id number is in there just removed it"

Enable the policy

Update-MgIdentityConditionalAccessPolicy -ConditionalAccessPolicyId $policyId -BodyParameter @{ state = "disabled" }

Write-Output "Policy has been DISABLED."

I dont think its loading the modules correctly from the zip

Any help would be amazing

Thanks

Lewis

Azure Automation
Azure Automation

An Azure service that is used to automate, configure, and install updates across hybrid environments.


1 answer

Sort by: Most helpful
  1. Suchitra Suregaunkar 14,595 Reputation points Microsoft External Staff Moderator
    2025-09-09T12:10:39.3866667+00:00

    Hello Lewis Venables

    Thank you for posting your query on Microsoft Q&A platform.

    You are trying to automate enabling or disabling a Conditional Access Policy in Azure using a PowerShell runbook and Microsoft Graph SDK, but you are facing two common issues that is

    1. Invalid JWT Access Token might be due to using managed identity without assigning the correct Microsoft Graph API application permissions.

    The Graph SDK version you are using expects delegated permissions, which are not supported in Azure Automation with managed identity.

    1. Cmdlet Not Recognized (Update-MgIdentityConditionalAccessPolicy): This happens when the required module (Microsoft.Graph.Identity.SignIns) is either not installed properly or missing dependencies. You manually uploaded a ZIP file that did not include all required submodules.

    Thanks,

    Suchitra.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.