Friday, June 14, 2013

SharePoint 2013: Listing out Existing SharePoint App Pools

The SharePoint App Pools that run your web applications exist in SharePoint whether or not they physically exist in IIS. I previously looked at consolidating some of these app pools to reduce the worker processes and memory consumption. I used this post as a guide.

However, my manager decided that he wanted all of the web apps to go back to using their own app pool. You can't just go and create a new app pool in IIS and assign it to your web app (technically you can but that's wrong).

I found a post here that creates a function for setting the app pool. You must know the name of the SharePoint App Pool. Since I previously deleted mine I used a reference in that function to list out the available SharePoint app pools:

[Microsoft.SharePoint.Administration.SPWebService]::ContentService.ApplicationPools | ft Name


You may use any of the existing names when calling the function in Ivan Josipovic's post.

Notice, however, the Central Admin app pool is not listed. The app pools listed are all for the content-based web applications. To get the administrative app pools, use this command:

[Microsoft.SharePoint.Administration.SPWebService]::AdministrationService.ApplicationPools | ft Name



I therefore created a new function to handle my Central Administration app pool change:

Function Set-WebCAApplicationPool($WebAppURL,$ApplicationPoolName){
    $apppool = [Microsoft.SharePoint.Administration.SPWebService]::AdministrationService.ApplicationPools | where {$_.Name -eq $ApplicationPoolName}
    if ($apppool -eq $null){
        write-host -foreground red "The Application Pool $ApplicationPoolName does not exist!"
        return 1
    }
    $webapp = get-spwebapplication -Identity $WebAppUrl
    if ($webapp -eq $null){
        write-host -foreground red "The Web Application $WebAppUrl does not exist!"
        return 1
    }
    $webapp.Applicationpool = $apppool
    $webApp.Update()
    $webApp.ProvisionGlobally()
    write-host -foreground green "$WebappURL Application Pool has been changed to $ApplicationPoolName"
    return 0
}

Set-WebCAApplicationPool -WebAppURL "http://SP2013SVR:12345" -ApplicationPoolName "SharePoint Central Administration v4"

Obtaining Service Application App Pools is much easier as there is a SharePoint PowerShell cmdlet for this:

Get-SPServiceApplicationPool | ft name



These are the Service Application Application Pools that are running on the entire farm - regardless of the server. I consolidated several Service Applications to use the SharePoint Web Services System pool if the services run on the same application server.

 

Wednesday, June 12, 2013

SharePoint 2013 Search: Getting a Value From the Previous Search Result

If you have been playing around with the new Search Display Templates, you have probably seen lots of references to ctx.CurrentItem. This is the current search result item from the result set. However, what about the previous item? Maybe you want to group results or only display certain values if the previous value is different than the current value. The value may be of any managed property or regular property of the CurrentItem object.

There isn't a PreviousItem object so I needed to figure out a different way to get to the previous item. The CurrentItem has a ParentTableReference which contains a collection of ResultRows. Perfect!

The ctx object stores the CurrentItemIdx which can be used to get a particular ResultRow and any property of the search result object (treat it like the CurrentItem).

So now I can get any result value relative to the current result item by using the index as a pointer. The previous item would be ctx.CurrentItemIdx - 1 and the next item would be ctx.CurrentItemIdx + 1.

Here is the logic in a nutshell:

<!--#_ 
        if (!Srch.U.n(ctx.CurrentItem.ParentTableReference) && ctx.CurrentItem.ParentTableReference.TotalRows > 1) {
           var previousIndex = ctx.CurrentItemIdx - 1;
           if (previousIndex >= 0)
           {
                var previousValue = ctx.CurrentItem.ParentTableReference.ResultRows[previousIndex].<<property>>;
               <<<add other conditions and set flags here>>
           }
        }
_#-->



You can now check the previous value of a property against the ctx.CurrentItem value of the property and alter the display or perform other functions accordingly.

Let me know if you find a better way!


 

Wednesday, June 5, 2013

SharePoint 2013 Search: Adding a New Admin Component to a Search Server

This blog is part of my Scaling Out Search Series and describes the processes for adding a new admin component to a new search server:

Get Search Service Instance and Start on New Index Server$ssi = Get-SPEnterpriseSearchServiceInstance -Identity "<<new index server>>"
Start-SPEnterpriseSearchServiceInstance -Identity $ssi


Wait for Search Service Instance to come online
Get-SPEnterpriseSearchServiceInstance -Identity $ssi

(The full script contains a loop that waits for the service to come online)

Clone Active Search Topology$ssa = Get-SPEnterpriseSearchServiceApplication
$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone –SearchTopology $active


Add New Admin ComponentNew-SPEnterpriseSearchAdminComponent -SearchTopology $clone -SearchServiceInstance $ssi



Activate the Cloned Search Topology
Set-SPEnterpriseSearchTopology -Identity $clone


Review new topology
Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa



Monitor Distribution of Index
Get-SPEnterpriseSearchStatus -SearchApplication $ssa


(The full script contains a loop that waits for the index component to be Active)

The new index component will be "Degraded" until the index is fully synced. Use the -text parameter to retrieve more detailed information.

Once all components are Active, reviewing the Search Application Topology in Central Admin shows the following:


My second search server was now complete!


FULL SCRIPT

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get Search Service Instance and Start on New Index Server
$ssi = Get-SPEnterpriseSearchServiceInstance -Identity "<<new index server>>"
Start-SPEnterpriseSearchServiceInstance -Identity $ssi


#Wait for Search Service Instance to come online
do {$online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; Write-Host "Waiting for service: " $online.Status}
until ($online.Status -eq "Online")


#Clone Active Search Topology
$ssa = Get-SPEnterpriseSearchServiceApplication
$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone –SearchTopology $active


# Add New Admin Component
New-SPEnterpriseSearchAdminComponent -SearchTopology $clone -SearchServiceInstance $ssi

#Activate the Cloned Search Topology
Set-SPEnterpriseSearchTopology -Identity $clone


#Review new topology
Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa


#Monitor Distribution of Index
do {$activeState = Get-SPEnterpriseSearchStatus -SearchApplication $ssa | Where-Object {$_.Name -eq "IndexComponent2"}; Write-Host "Waiting for active distribution: " $activeState.State}
until ($activeState.State -eq "Active")

SharePoint 2013 Search: Adding a New Analytics Component to a Search Server

This blog is part of my Scaling Out Search Series and describes the processes for adding a new analytics component to a new search server:

Get Search Service Instance and Start on New Index Server$ssi = Get-SPEnterpriseSearchServiceInstance -Identity "<<new index server>>"
Start-SPEnterpriseSearchServiceInstance -Identity $ssi


Wait for Search Service Instance to come online
Get-SPEnterpriseSearchServiceInstance -Identity $ssi

(The full script contains a loop that waits for the service to come online)

Clone Active Search Topology$ssa = Get-SPEnterpriseSearchServiceApplication
$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone –SearchTopology $active


Add New Analytics Processing Component
New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $clone -SearchServiceInstance $ssi



Activate the Cloned Search Topology
Set-SPEnterpriseSearchTopology -Identity $clone


Review new topology
Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa



Monitor Distribution of Index
Get-SPEnterpriseSearchStatus -SearchApplication $ssa


(The full script contains a loop that waits for the index component to be Active)

The new index component will be "Degraded" until the index is fully synced. Use the -text parameter to retrieve more detailed information.

Once all components are Active, reviewing the Search Application Topology in Central Admin shows the following:

NEXT, I created a New Admin Component.



FULL SCRIPT

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get Search Service Instance and Start on New Index Server
$ssi = Get-SPEnterpriseSearchServiceInstance -Identity "<<new index server>>"
Start-SPEnterpriseSearchServiceInstance -Identity $ssi


#Wait for Search Service Instance to come online
do {$online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; Write-Host "Waiting for service: " $online.Status}
until ($online.Status -eq "Online")


#Clone Active Search Topology
$ssa = Get-SPEnterpriseSearchServiceApplication
$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone –SearchTopology $active


# Add New Analytics Processing Component
New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $clone -SearchServiceInstance $ssi

#Activate the Cloned Search Topology
Set-SPEnterpriseSearchTopology -Identity $clone


#Review new topology
Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa


#Monitor Distribution of Index
do {$activeState = Get-SPEnterpriseSearchStatus -SearchApplication $ssa | Where-Object {$_.Name -eq "IndexComponent2"}; Write-Host "Waiting for active distribution: " $activeState.State}
until ($activeState.State -eq "Active")

SharePoint 2013 Search: Adding a New Content Processing Component to a Search Server

This blog is part of my Scaling Out Search Series and describes the processes for adding a new content processing component to a new search server:

Get Search Service Instance and Start on New Index Server$ssi = Get-SPEnterpriseSearchServiceInstance -Identity "<<new index server>>"
Start-SPEnterpriseSearchServiceInstance -Identity $ssi


Wait for Search Service Instance to come online
Get-SPEnterpriseSearchServiceInstance -Identity $ssi

(The full script contains a loop that waits for the service to come online)

Clone Active Search Topology$ssa = Get-SPEnterpriseSearchServiceApplication
$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone –SearchTopology $active


Add New Content Processing Component
New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $clone -SearchServiceInstance $ssi


Activate the Cloned Search Topology
Set-SPEnterpriseSearchTopology -Identity $clone


Review new topology
Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa



Monitor Distribution of Index
Get-SPEnterpriseSearchStatus -SearchApplication $ssa


(The full script contains a loop that waits for the index component to be Active)

The new index component will be "Degraded" until the index is fully synced. Use the -text parameter to retrieve more detailed information.

Once all components are Active, reviewing the Search Application Topology in Central Admin shows the following:


NEXT, I created a New Analytics Component.


FULL SCRIPT

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get Search Service Instance and Start on New Index Server
$ssi = Get-SPEnterpriseSearchServiceInstance -Identity "<<new index server>>"
Start-SPEnterpriseSearchServiceInstance -Identity $ssi


#Wait for Search Service Instance to come online
do {$online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; Write-Host "Waiting for service: " $online.Status}
until ($online.Status -eq "Online")


#Clone Active Search Topology
$ssa = Get-SPEnterpriseSearchServiceApplication
$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone –SearchTopology $active


# Add New Content Processing Component
New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $clone -SearchServiceInstance $ssi

#Activate the Cloned Search Topology
Set-SPEnterpriseSearchTopology -Identity $clone


#Review new topology
Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa


#Monitor Distribution of Index
do {$activeState = Get-SPEnterpriseSearchStatus -SearchApplication $ssa | Where-Object {$_.Name -eq "IndexComponent2"}; Write-Host "Waiting for active distribution: " $activeState.State}
until ($activeState.State -eq "Active")