Archivo de la etiqueta: State Service

SharePoint 2013 – Script de aprovisionamiento de Usage and State Service Applications

powershellLa aplicación de Servicio de estado (o State Service) proporciona almacenamiento temporal de los datos de usuario para los componentes de SharePoint 2013.

Para crear este servicio en SharePoint 2013, aquí tenéis un script de PowerShell que os puede ser de utilidad, si estáis montando nuevos entornos:

#####################################################################################
## Create Usage and State Service Applications ##
#####################################################################################
$DB = "DES-SP2013"

$DataDrive = "C:\\SPLogs"
$USName = "Usage and Health Data Collection Service"
$USDB = "SP2013_Usage"

$SSName = "State Service"
$SSDB = "SP2013_State"
#####################################################################################
## Administrative Privileges Check ##
#####################################################################################
function Use-RunAs 
{    
    # Check if script is running as Adminstrator and if not use RunAs 
    # Use Check Switch to check if admin 
    param([Switch]$Check) 
	$IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") 
    if ($Check) { return $IsAdmin }     
    if ($MyInvocation.ScriptName -ne "") 
    {  
        if (-not $IsAdmin)  
        {  
            try 
            {  
                $arg = "-file $($MyInvocation.ScriptName)" 
                Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList $arg -ErrorAction "stop"  
            } 
            catch 
            { 
                Write-Warning "Error - Failed to restart script with runas"  
                break
            } 
            exit # Quit this session of powershell 
        }  
    }  
    else
    {  
        Write-Warning "Error - Script must be saved as a .ps1 file first"  
        break  
    }  
} 
Use-RunAs
#####################################################################################
## Add Powershell SharePoint Snapin
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
#####################################################################################
try
{
	Write-Host "Creating Usage and Health Data Collection Service"
	Set-SPUsageService -LoggingEnabled 1 -UsageLogLocation "$DataDrive" -UsageLogMaxSpaceGB 2
	$serviceInstance = Get-SPUsageService
	New-SPUsageApplication -Name $USName -DatabaseServer $DB -DatabaseName $USDB -UsageService $serviceInstance > $null
	Write-Host "Service created correctly"

	Write-Host "Creating State Service and Proxy…"
	$stateServiceDatabase = New-SPStateServiceDatabase -Name $SSDB
	$stateSA = New-SPStateServiceApplication -Name $SSName -Database $stateServiceDatabase
	New-SPStateServiceApplicationProxy -ServiceApplication $stateSA -Name "$SSName Proxy" -DefaultProxyGroup
	Write-Host "Service created correctly"
} 
catch 
{ 
	Write-Output $_  
} 

 

Referencias: New-SPUsageApplication, New-SPStateServiceDatabase y New-SPStateServiceApplicationProxy