Creating the Search Service Application in SharePoint 2013 Server
While you can create your Search
service application in Central Admin, doing so will create all your
Search databases with GUIDs at the end. No one likes GUIDs. They were
always picked last for kickball in grade school, every, single, time.
If you instead create the Search service with PowerShell, you can
specify the database names SharePoint should use. The following script
will do that for you (note that it assumes that the service application
pool from the previous section exists):
# Get App Pool
$saAppPoolName = "Default SharePoint Service App Pool"
# Search Specifics, we are single server farm
$searchServerName = (Get-ChildItem env:computername).value
$serviceAppName = "Search Service Application"
$searchDBName = "SearchService_DB"
# Grab the Appplication Pool for Service Application Endpoint
$saAppPool = Get-SPServiceApplicationPool $saAppPoolName
# Start Search Service Instances
Write-Host "Starting Search Service Instances..."
Start-SPEnterpriseSearchServiceInstance $searchServerName
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $searchServerName
# Create the Search Service Application and Proxy
Write-Host "Creating Search Service Application and Proxy..."
$searchServiceApp = New-SPEnterpriseSearchServiceApplication -Name $serviceAppName
-ApplicationPool $saAppPoolName -DatabaseName $searchDBName
$searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "$serviceAppName
Proxy" -SearchApplication $searchServiceApp
# Clone the default Topology (which is empty) and create a new one and then
activate it
Write-Host "Configuring Search Component Topology..."
$clone = $searchServiceApp.ActiveTopology.Clone()
$searchServiceInstance = Get-SPEnterpriseSearchServiceInstance
New-SPEnterpriseSearchAdminComponent –SearchTopology $clone –SearchServiceInstance
$searchServiceInstance
New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone
-SearchServiceInstance $searchServiceInstance
New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone
-SearchServiceInstance $searchServiceInstance
New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone
-SearchServiceInstance $searchServiceInstance
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone
-SearchServiceInstance $searchServiceInstance
New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone
-SearchServiceInstance $searchServiceInstance
$clone.Activate()
Write-Host "Search Done!"
After running this script, head over to Central Admin and enjoy the fruits of your labor.
Creating a Claims Web Application
following little beauty will
create a new web application and use claims-based authentication:
$ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication
-DisableKerberos
New-SPWebApplication -Name "Contoso Portal"
-ApplicationPool "Default SharePoint Web Apps"
-HostHeader portal.contoso.com -Port 80 -Url http://portal.contoso.com
-AuthenticationMethod NTLM -AuthenticationProvider $ap
-DatabaseName "WSS_Content_Portal"
Getting Site Collection Size
You can use this one-liner to list all the site collections in your farm, sorted by size:
Get-SPSite | select url, @{label="Size in MB";Expression={$_.usage.storage/1MB}} |
Sort-Object -Descending -Property "Size in MB" | Format-Table –AutoSize
Getting Database Size
The following will list all the databases in your farm, sorted by size:
Get-SPDatabase | select name, @{label="Size in MB";Expression=
{$_.disksizerequired/1MB}} | Sort-Object -Descending -Property "Size in MB"
Hopefully you’ll be able to grab some useful nuggets from these scripts and write some amazing scripts of your own.