Skip to content

Instantly share code, notes, and snippets.

@rheid
Created September 4, 2014 10:54
Show Gist options
  • Select an option

  • Save rheid/93fad58069b1a62e786b to your computer and use it in GitHub Desktop.

Select an option

Save rheid/93fad58069b1a62e786b to your computer and use it in GitHub Desktop.
Setup new The State Service
# The State Service is required in order to use the out-of-the-box workflows in
# SharePoint Server 2010 (e.g. Approval - SharePoint 2010) or any other features
# that leverage InfoPath Forms Services.
#
# When using the Farm Configuration Wizard to configure the State Service, the
# resulting database is named StateService_{GUID}. In order to avoid lengthy
# database names containing GUIDs, the State Service is configured using PowerShell.
function ConfigureStateService(
[string] $stateServiceName = $(Throw "Value cannot be null: stateServiceName"),
[string] $stateServiceDatabaseName =
$(Throw "Value cannot be null: stateServiceDatabaseName"))
{
Write-Host "Configuring the State Service..."
Write-Debug "stateServiceName: $stateServiceName"
Write-Debug "stateServiceDatabaseName: $stateServiceDatabaseName"
$serviceApp = Get-SPStateServiceApplication -Identity "$stateServiceName" `
-Debug:$false -EA 0
If ($serviceApp -ne $null)
{
Write-Host "The State Service has already been configured."
return
}
$database = New-SPStateServiceDatabase -Name $stateServiceDatabaseName `
-Debug:$false
$serviceApp = New-SPStateServiceApplication -Name $stateServiceName `
-Database $database -Debug:$false
New-SPStateServiceApplicationProxy -ServiceApplication $serviceApp `
-Name $stateServiceName -DefaultProxyGroup -Debug:$false > $null
Write-Host -Fore Green "Successfully configured the State Service."
}
function Main()
{
$stateServiceName = "State Service"
$stateServiceDatabaseName = "HDTP_States"
ConfigureStateService $stateServiceName $stateServiceDatabaseName
}
Main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment