How To: Set security timeouts in SharePoint 2010 using PowerShell

SharePoint 2010 allows you to set timeout of the user session so that your users are logged out after certain time of inactivity. Also, SharePoint allows you to configure the timeout for the current page state to expire. This is handy for forms which have to be filled within a certain period of time before they expire.

Alternatively, if you want to extend the timeout – you can do that too.

First, let’s take a look at how you can expire page content after a given time using PowerShell:

Open SharePoint 2010 Management Shell as administrator and execute the following:

$SPSite = Get-SPSite("[your site collection]")
$webApp = $SPSite.WebApplication
$webApp.FormDigestSettings.Enabled = $true
$webApp.FormDigestSettings.Expires = $true
$webApp.FormDigestSettings.Timeout = New-TimeSpan -Hours 2 -Minutes 30
$webApp.Update()

This will effectively enable expiration and set page content to expire after users leave it hanging for over 2 hours and 30 minutes.

Also, if you’re using claims authentication and would like for your provider to expire sessions after certain period of inactivity, here is how to do that with PowerShell:

$sts = Get-SPSecurityTokenServiceConfig
$sts.UseSessionCookies = $true
$sts.LogonTokenCacheExpirationWindow = New-TimeSpan -Minutes 5
$sts.Update()

This will set our logon expiration to 5 minutes.

By the way, for more PowerShell goodies be sure to check out my new book

Enjoy!

This entry was posted in sharepoint, sharepoint 2010 and tagged , , . Bookmark the permalink.

One Response to How To: Set security timeouts in SharePoint 2010 using PowerShell

  1. Pingback: Sharepoint Updates November-26-2011 | SDavara's Sharepoint Knowledge Center