This information is based on a public beta of SharePoint 2010.

You may already know there are over 500 PowerShell Cmdlets available to you to configure SharePoint 2010. Figuring out which Cmdlet to use isn't straightforward but you will get familiar with the convention quickly. With that many Cmdlets available to me, I imagine I will never have to visit the Central Administration Site ever again! Having said that, it is a good starting point to learn about what settings are available to you. The process of provisioning a service application is roughly broken down into these steps:

  1. Start the Service Instance [optional ]
  2. Create a IIS Web Service Application Pool
  3. Create the Service Application by calling New-SPXXXXServiceApplication
  4. Create the Service Application Proxy by calling New-SPXXXServiceApplicationProxy

One of the most requested features in SharePoint 2010 is the new Metadata Service and I'll use it as an example:

StartServiceInstance "Managed Metadata Web Service"

$MetadataServiceName = "Metadata Service" 
$DatabaseServer=$($Env:COMPUTERNAME)
$MetadataServiceDB = "MetadataDB"

if ((Get-SPMetadataServiceApplication -Identity $MetadataServiceName) -eq $null)
{
	$AppPool = Get-SPIisWebServiceApplicationPool | Where-Object { $_.Name -like "SharePoint Web Services System" }

	Write-Host "Creating Metadata Service Application - $MetadataServiceName ..."

	$MetaSvcApp = New-SPMetadataServiceApplication -Name $MetadataServiceName `
	-AdministratorAccount "AD\Administrator" -FullAccessAccount "AD\SP2010_SvcFarm" `
	-DatabaseServer $DatabaseServer -DatabaseName $MetadataServiceDB -ApplicationPool $AppPool 
	
	Write-Host "Creating Metadata Service Application Proxy - $MetadataServiceName ..."

	$MetaSvcAppProxy = New-SPMetadataServiceApplicationProxy `
	-Name $MetadataServiceName `
	-ServiceApplication $MetaSvcApp `
	-DefaultKeywordTaxonomy -DefaultProxyGroup 
	
	Write-Host "Service Application created."
}
else
{
	Write-Host "$MetadataServiceName already exists." -BackgroundColor Blue
}

The StartServiceInstance function looks like this:

function StartServiceInstance($serviceName)
{
	$serviceInstance = (Get-SPServiceInstance |?{$_.TypeName -eq $serviceName })
	
	if ($serviceInstance -ne $null)
	{
		Write-Progress -Activity "Starting $serviceName" -Status "Starting"	
		
		Start-SPServiceInstance $serviceInstance
		
		while($serviceInstance.Status -ne "Online")
		{
			Write-Progress -Activity "Waiting for $serviceName to come online" -Status "Waiting"	
			Sleep 5;
			$serviceInstance = (Get-SPServiceInstance |?{$_.TypeName -eq $serviceName })	
		}
		
		Write-Progress -Activity "Waiting for $serviceName to come online" -Status "Completed"	 -Completed
	}
	else
	{
		Write-Host "$serviceName is already running"
	}	
}

		

Share