Reducing Time to Install Cumulative Updates and Service Packs


I was involved in deploying SharePoint 2013 cumulative updates and service packs in our customer environment packs and it was taking very long time for us to complete the installations. We provide a Cloud Based SharePoint 2013 Environments which have very large number of servers as well as extended search topologies which make the process to complete in even more time. I had made my own process which include stopping SharePoint Server Search, Search Controller and Timer service manually or with PowerShell before running the CU but still it was not good. So after some research I was able to find out a way to do it faster. This may not be new to you but I have been using it from last 10 months or so I documented it below.

I found this great post from Russ Maxwell that
had this great script that can automated the whole process.

http://blogs.msdn.com/b/russmax/archive/2013/04/01/why-sharepoint-2013-cumulative-update-takes-5-ours-to-install.aspx

  1. I copied the script from there and put into a PS1 file.
  2. Download the Cumulative Update in the same folder as PowerShell script and then copy the folder to all SharePoint Servers.

  1. Before you go to step 3 Open Central Administration and Go to Manage Service Application à Search Service Application
  2. Open PowerShell as Administrator
  3. Switch to CU and PowerShell folder
  4. Now I always start from the Central Administration server but you can start from any other server.

  1. Press 1 and Enter

If you refresh Search Center you will see that Search service application is paused.

Note: I have seen that some time script take very long time to go to next time. To save time the tip is that you can press Control C and then start again with 2. Just verify that Search service application is paused.


  1. Now Login to other server and Repeat the same process with Option
    “2” now wait for installation process to complete on all servers.
  2. Once the service application will be paused it will automatically stop the services and start the installation of CU.



  1. Make sure the installation is complete on all server.
  2. Go to any server in the Farm and In the same PowerShell Window type the following

psconfig -cmd upgrade -inplace b2b –force -wait

Note (STS Error message is on last page):

To Avoid STS Error after running the wizard.

When PSConfig reach step 2. Do IISRESET on another command prompt.

  1. If you upgrade failed with error you can check in two placed
    1. DateTime-UpgradeError.log : that contains the main error for your upgrade to fail + any warnings.
    2. Detailed Upgrade-DateTime.log that contains verbose logs of the whole upgrade process.
  2. What kind of issues I have encountered.
    1. Missing Features that I have to remove suing Feature Admin from CodePlex
    2. Orphan Sites and Webs
  3. It is not required but you can Now Run SharePoint Configuration Wizard and then click Next, Next, Finish

  1. Upgrade and Migration à Review Database Status à make sure all databases are no action required.
  2. I have seen that mostly BDC Database goes into compatibility Range. Following my Blog here to fix that.

  1. Upgrade and Migration à Check Product and Patch installation status à Your KB must be listed.

Login to SQL Server à Open SQL Server Management Studio à Click Connect

Expand Databases à Expand SharePoint Configuration or any Content Databases à Expand Tables

Right click on Versions à View Top 10

Verify the version against Todd Klindt’s http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=346

 

 

REmoving Service Applications


If you are planning to cleanup your service applications and stop the services you can use the PowerShell script below.  Below script does not cover all service applications.

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

$AccessServiceProxy = Get-SPServiceApplicationProxy | ?{$_.Name -eq "Access"}
if($AccessServiceProxy -ne $null)
{
    Remove-SPServiceApplicationProxy $AccessServiceProxy -RemoveData -Confirm:$false
    Write-Host -ForegroundColor Green "Access Service Application Proxy is Deleted" 
}
else { Write-Host -ForegroundColor Red "Did not found Access Service Application Proxy"  }

$AccessService = Get-SPServiceApplication | ?{$_.Name -eq "Access"}
if($AccessService -ne $null)
{
    Remove-SPServiceApplication $AccessService -RemoveData -Confirm:$false
    Write-Host -ForegroundColor Green "Access Service Application is Deleted" 
}
else { Write-Host -ForegroundColor Red "Did not found Access Service Application"  }
$AccessServiceInstance = Get-SPServiceInstance | ? {$_.TypeName -eq "Access Database Service 2010"}
$AccessServiceInstance | Stop-SPServiceInstance -Confirm:$false


$PowerPointProxy = Get-SPServiceApplicationProxy | ?{$_.Name -eq "PowerPointConversion Proxy"}
if($PowerPointProxy -ne $null)
{
    Remove-SPServiceApplicationProxy $PowerPointProxy -RemoveData -Confirm:$false
}
else { Write-Host "Did not found PowerPoint Service Application Proxy" }

$PowerPoint = Get-SPServiceApplication | ?{$_.Name -eq "PowerPointConversion"}
if($PowerPoint -ne $null)
{
    Remove-SPServiceApplication $PowerPoint -RemoveData -Confirm:$false
}
else { Write-Host "Did not found PowerPoint Service Application" }
Sleep 2
$PowerPointServiceInstance = Get-SPServiceInstance | ? {$_.TypeName -eq "PowerPoint Conversion Service"}
$PowerPointServiceInstance | Stop-SPServiceInstance -Confirm:$false

$MachineProxy = Get-SPServiceApplicationProxy | ?{$_.Name -eq "MachineTranslation"}
if($MachineProxy -ne $null)
{
    Remove-SPServiceApplicationProxy $MachineProxy -RemoveData
}
else { Write-Host "Did not found Machine Translation Service Application" }
$Machine = Get-SPServiceApplication | ?{$_.Name -eq "MachineTranslation"}
if($Machine -ne $null)
{
    Remove-SPServiceApplication $Machine -RemoveData
}
else { Write-Host "Did not found Machine Translation Service Application" }
Sleep 2
$MachineServiceInstance = Get-SPServiceInstance | ? {$_.TypeName -eq "Machine Translation Service"}
$MachineServiceInstance | Stop-SPServiceInstance -Confirm:$false

$VisioProxy  = Get-SPServiceApplicationProxy | ?{$_.Name -eq "VisioGraphics Proxy"}
if($VisioProxy -ne $null)
{
    Remove-SPServiceApplicationProxy $VisioProxy -RemoveData  -Confirm:$false
}
else { Write-Host "Did not found Visio Service Application" }

$Visio  = Get-SPServiceApplication | ?{$_.Name -eq "VisioGraphics"}
if($Visio -ne $null)
{
Remove-SPServiceApplication $Visio -RemoveData  -Confirm:$false
}
else { Write-Host "Did not found Visio Service Application" }
Sleep 2
$VisioServiceInstance = Get-SPServiceInstance | ? {$_.TypeName -eq "Visio Graphics Service"}
$VisioServiceInstance | Stop-SPServiceInstance -Confirm:$false

$WordAutomationProxy = Get-SPServiceApplicationProxy | ?{$_.Name -eq "WordAutomation"}
if($WordAutomationProxy -ne $null)
{
    Remove-SPServiceApplicationProxy $WordAutomationProxy -RemoveData  -Confirm:$false
}
else { Write-Host "Did not found Word Automation Service Application" }

$WordAutomation = Get-SPServiceApplication | ?{$_.Name -eq "WordAutomation"}
if($WordAutomation -ne $null)
{
Remove-SPServiceApplication $WordAutomation -RemoveData  -Confirm:$false
}
else { Write-Host "Did not found Word Automation Service Application" }
Sleep 2
$WordAutomationServiceInstance = Get-SPServiceInstance | ? {$_.TypeName -eq "Word Automation Services"}
$WordAutomationServiceInstance | Stop-SPServiceInstance -Confirm:$false

Get sharpoin library size


The below script can be Usedthe to check the size of SharePoint Library.  you have to pas the Web URL.  With litle change in the script you can make it for site collection.

function Get-SPListSize
{
    [CmdletBinding()]
    [OutputType([int])]
    Param
    (
        # Param1 help description
        [Parameter(Mandatory=$true,
                   ValueFromPipeLine=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=0)]
        [validteNoNull()]
        [Microsoft.SharePoint.SPWeb]$Web
    )

    Begin
    {
    }
    Process
    {
       foreach($List in $web.Lists)
       {
            if($list-isnot [Microsoft.SharePoint.SPDocumentLibrary]) {contine}
            $size = 0
            foreach($item in $list.Items)
            {
                $size = $item.File.Length
                foreach($version in $item.Versions)
                {
                    $size += $version.Size
                }
            }
            $data = @{"List" = $list.RootFolder.ServerRelativeUrl
                      "Size" = $size
                      "Size (MB)" = "{0:0:00}" -F ($size / 1MB)
                      "Size (GB)" = "{0,0,00}" -F ($size / 1GB)
                      }
            $o = New-Object -TypeName PSObjet -Property $data
            Write-Output $o

       }

    }
    End
    {
    }
}

add or remove search component in sharpoint 2013


Recently I faced an issue where one of the search index partition failed to become active and was in Degraded state for long time.  after lot of effort on trying to fix it, I decided to remove the bad partition and add it again. 

I have to clone the existing search topology and then remove the bad component and then add it again.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0 
#set Search Service Application
$ssa = Get-SPEnterpriseSearchServiceApplication
$ssa.pause()

# Check the status of the service application in a new Powershell windoe.
$ssa.IsPaused() -ne 0

#recreate search topology with new index component
#reset the index if the bad component is the index

#grab component name of faulty topology component and it's respective server name
Get-SPEnterpriseSearchStatus -SearchApplication $ssa -Text

#put server name where [SERVER] is.. remove the []
$hosta = get-spenterprisesearchserviceinstance -identity "USALSECS076"

#get the existing topology
$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active

#copy the existing topology
$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone -SearchTopology $active

Get-SPEnterpriseSearchComponent -SearchTopology $clone

#remove the bad component, placing the name where [BAD COMPONENT NAME] is... remove the []
$ComponentID = (Get-SPEnterpriseSearchComponent -SearchTopology $clone -Identity "IndexComponent4").componentID
Remove-SPEnterpriseSearchComponent -Identity $ComponentID.GUID -SearchTopology $clone -confirm:$false

#create the new component, the example below is for the index specifically - create a new folder for the index so it's empty!
New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance $hostA -IndexPartition 0

#Set this copy as the active topology
Set-SPEnterpriseSearchTopology -identity $clone

$active 
#Note the ID of the Topology and then Remove it.
#Remove-SPEnterpriseSearchTopology -Identity 9c1a5c17-b470-436f-bb8c-dc73ec3eaeda -SearchApplication $ssa

$ssa.resume()
#or
$ssa.ResumeAfterIndexRepartitioning()