Skip to content

Instantly share code, notes, and snippets.

@janikvonrotz
Created April 3, 2014 07:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save janikvonrotz/9950021 to your computer and use it in GitHub Desktop.
Save janikvonrotz/9950021 to your computer and use it in GitHub Desktop.
PowerShell: Update SharePoint Token Lifetime #SharePoint #PowerShell
if(-not (Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue)){Add-PSSnapin "Microsoft.SharePoint.PowerShell"}
# update SharePoint cache token lifetime
$SPContentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$SPContentService.TokenTimeout = (New-TimeSpan -minutes 5)
$SPContentService.Update()
# udpate SharePoint claims token lifetime
$SPSecurityTokenServiceConfig = Get-SPSecurityTokenServiceConfig
$SPSecurityTokenServiceConfig.WindowsTokenLifetime = (New-TimeSpan –minutes 5)
$SPSecurityTokenServiceConfig.FormsTokenLifetime = (New-TimeSpan -minutes 5)
# if you happen to set a lifetime that is shorter than the expiration window user will be blocked from accessing the site.
$SPSecurityTokenServiceConfig.LogonTokenCacheExpirationWindow = (New-TimeSpan -minutes 4)
$SPSecurityTokenServiceConfig.Update()
iisreset.exe
@AndreaSoto
Copy link

Thanks! This is working pretty good for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment