SharePoint 2013

Applies to: SharePoint Server 2013 Enterprise

Topic Last Modified: 2015-03-09

Creates and provisions a new state service database, and installs the state database schema into it.

New-SPStateServiceDatabase [-Name] <String> [-AssignmentCollection <SPAssignmentCollection>] [-DatabaseCredentials <PSCredential>] [-DatabaseServer <String>] [-ServiceApplication <SPStateServiceApplicationPipeBind>] [-Weight <Nullable>]

The New-SPStateServiceDatabase cmdlet creates and a new state service database. This cmdlet installs the session state database schema in the state service database.

SharePoint Management Shell


Parameter Required Type Description




Specifies the name for the state service database that is stored in SQL Server.




Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.




Specifies the database credentials for SQL Authentication used to access the state service database. If this parameter is not specified, Windows authentication is used.

The type must be a valid PSCredential object.




Specifies the name of the host server for the state service database.

The type must be a valid SQL Server host name; for example, SQLServerHost1.




Specifies the state service application to add the state database to.

The type must be a valid name of a state service application (for example, StateServiceApp1); a valid GUID, in the form 12345678-90ab-cdef-1234-567890bcdefgh; or an instance of a valid SPStateServiceApplication object.




Specifies the weight for the state database. The default value is 1.

This parameter is used when new rows of data are allocated among the collection of databases that are associated with a service application

The type must be a valid integer in the range of 1 to 10.

--------------EXAMPLE 1-----------------

Get-SPStateServiceApplication -name "State Service Application 1" | New-SPStateServiceDatabase -Name "statedata1" -DatabaseServer "localhost"

This example creates a new state service database by using Windows authentication, and associates it with the provided service application.

--------------EXAMPLE 2-----------------

$cred = Get-Credential
Get-SPStateServiceApplication -name "State Service Application 1" | New-SPStateServiceDatabase -Name "statedata1" -DatabaseServer "localhost" -DatabaseCredentials $cred

This example creates a new state service database, a new state service application associated with the database and a new state service application proxy associated with the state service application proxy.

This example configures all the objects required to have State Service operational on a farm.