WSS Usage Application SP2010 PowerShell script

Use this script to create a WSS Usage Application in a SharePoint 2010 farm with a nice DataBase name.

# <# # .DESCRIPTION #		This script is for creating WSS Usage Application in SharePoint 2010 #		with a 'clean' database name. # # .USAGE #		Run this PS script on the admin server, start the PS as administrator #		with enough database permissions. # # .NOTES #		File Name	: Create_wss_usage_app.ps1 #		Author		: Ronald Bruinsma @ iDocs #		Requires	: PowerShell Version 2.0 #		Date		: 24 September 2010 # # .LINK #		URL		: http://www.idocs.info # #>
# ##
# # Start of script
# ##

#Include the SharePoint cmdlets:
#Add-PsSnapin Microsoft.SharePoint.PowerShell # remove first '#' if needed

try
{
	$CheckSPUsageApplicationExists = Get-SPUsageApplication
	If ($CheckSPUsageApplicationExists -eq $Null)
	{
	# First some variables:
	$WSSUsageApplicationName	= read-host -prompt 'Name for the WSS Usage Application'
	$DBServerName				= read-host -prompt 'Database server name (use FQDN)'
	$WSSUsageDataBaseName		= read-host -prompt 'Database name for this appliction'

		Write-Host "Creating WSS Usage Application..."
		New-SPUsageApplication -Name $WSSUsageApplicationName -DatabaseServer $DBServerName -DatabaseName $WSSUsageDataBaseName | Out-Null
		Write-Host "Created WSS Usage Application."
	}
	Else {Write-Host "WSS Usage Application allready exists..."}
}
catch
{
		Write-Output $_
}

5 thoughts on “WSS Usage Application SP2010 PowerShell script

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>