Skip to content

Instantly share code, notes, and snippets.

@OlafD
Last active April 15, 2020 11:26
Show Gist options
  • Save OlafD/b704264f697cae0d6e3f9ae419bc91c2 to your computer and use it in GitHub Desktop.
Save OlafD/b704264f697cae0d6e3f9ae419bc91c2 to your computer and use it in GitHub Desktop.
Set the access token lifetime in Azure AD for the whole organization. In the script it will be set to 10min, the minimum possible. Needs the module Azure AD PowerShell 2.0, To run connect with Connect-AzureAD to your directory.
$policy = New-AzureADPolicy `
-Definition @('{"TokenLifetimePolicy":{"Version":1,"AccessTokenLifetime":"00:10:00","MaxAgeSessionSingleFactor":"00:10:00"}}') `
-DisplayName "WebPolicyScenario" `
-IsOrganizationDefault $true `
-Type "TokenLifetimePolicy"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment