# Changing token lifetime policy

**URL:** <https://forums.powershell.org/t/changing-token-lifetime-policy/15739>\
**Category:** PowerShell Help\
**Created:** [February 25, 2021, 4:36pm UTC](https://forums.powershell.org/t/changing-token-lifetime-policy/15739 "2021-02-25T16:36:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SamParrington](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@SamParrington](https://forums.powershell.org/u/SamParrington)\
**Post date:** [February 25, 2021, 4:36pm UTC](https://forums.powershell.org/t/changing-token-lifetime-policy/15739/1 "2021-02-25T16:36:36Z")

</div>

Hi,

I’m trying to change the “token lifetime policy” in Azure via PowerShell, but it doesnt seem to work. I’ve  
search through google for different ideas and syntaxes and nothing seems to work

This is what i have so far;

# Authenticate ad global admin user for tenant

connect-AzureAD -Confirm

# Create Access policy with token lifetime set to 12hrs

$policy = New-AzureADPolicy -Definition @(‘{“TokenLifetimePolicy”:{“Version”:1,“AccessTokenLifetime”:“12:00:00”}}’) -DisplayName “P4AccessPolicy” -IsOrganizationDefault $false -Type “TokenLifetimePolicy”

# Verify policy has been created

get-azureadpolicy

# List AzureAD linked applications, Public14 should be listed, make a note of the the ObjectId

get-azureadapplication

# Assign the newly created policy to the Public14 application using the App Object ID & Policy ID

Add-AzureADApplicationPolicy -Id -RefObjectId $policy.id

# Verify the Policy has been applied - this should report an Odatatype of “microsoft.graph.application”

Get-AzureADPolicyAppliedObject -Id $policy.id

If anyone could help that would be amazing

Thank you all

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [February 25, 2021, 8:47pm UTC](https://forums.powershell.org/t/changing-token-lifetime-policy/15739/2 "2021-02-25T20:47:44Z")

</div>

That is a very specific Azure question and with no errors it’s going to be difficult to assist if it is not simply not being set. Recommend that you look in Azure forums and if you cannot find the answer start a thread there:

[Search - 9 results found - Microsoft Q&A](https://docs.microsoft.com/en-us/answers/search.html?c=&includeChildren=&f=&type=question+OR+idea+OR+kbentry+OR+answer+OR+topic+OR+user&redirect=search%2Fsearch&sort=relevance&q=TokenLifetimePolicy)

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:27pm UTC](https://forums.powershell.org/t/changing-token-lifetime-policy/15739/3 "2024-05-16T20:27:49Z")

</div>


