Monday, August 25, 2014

SharePoint trouble shooting - update list data without event receiver triggered in powershell

Sometimes we need to run powershell to do batch update some list items, if the event receiver is active, the update process can be very slow. In this case, we will want to turn it off before batch update, then turn it back on.

Here is the powershell script to complete this,

# disable event firing
$my = [Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint");
$type = $my.GetType("Microsoft.SharePoint.SPEventManager");
$prop = $type.GetProperty([string]"EventFiringDisabled",[System.Reflection.BindingFlags] ([System.Reflection.BindingFlags]::NonPublic -bor [System.Reflection.BindingFlags]::Static));
$prop.SetValue($null, $true, $null);
**** run times update ****

# enable event firing
$prop.SetValue($null, $false, $null);


Wednesday, August 20, 2014

SharePoint trouble shooting - error to load excel in webpart page

The ULS log shows the error as below,

Unable to create or access workbook cache at C:\Windows\TEMP\Excel Server\FileCache\46deae92-790c-4b89-86e3-3719a2edcf01\Ranges. Excel Services Application is unable to function without a workbook cache.

CachedFile.SaveFile: Threw exception: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Windows\TEMP\Excel Server\FileCache\46deae92-790c-4b89-86e3-3719a2edcf01\Ranges\5dfc1857-7543-4418-9cf1-37102e27d6fb.xlsrvrng'.
1. Run Power shell command $app = Get-SPExcelServiceApplication , $app.ApplicationPool to check if the service account has the permission to the folder
 
C:\Windows\TEMP\Excel Server

2. Just delete the excel service application folders in the cache and refresh, then it worked.

SharePoint trouble shooting - Remove orphan feature

In the ULS log, the following error message keep happening because the feature has been removed from the solution before the feature undeployed.

Feature definition missing for Feature <<feature display name>>' (Id: '2cf0c09e-157e-4d3b-aa61-fee768b489c9'; CompatibilityLevel: '15')

The following powershell script can be used to identity the orphan features,

$url = "<site url>"
$site= new-Object Microsoft.SharePoint.SPSite($url)
$site.WebApplication.Farm.FeatureDefinitions `
| where-object {$_.solutionid -ne '00000000-0000-0000-0000-000000000000'} `
| Sort-Object solutionid,displayname `
| ft -property solutionid,id, displayname,scope -auto > features.txt
$features = $site.WebApplication.Farm.FeatureDefinitions | where-object {$_.Scope -eq $null} | Sort-Object solutionid,displayname
$features | foreach {
 $id = $_.Id
}
$site.Dispose()

In codeplex, there is a good tool to remove the feature,
http://featureadmin.codeplex.com/

Just download it and use it the remove the orphan feature.




SharePoint trouble shooting - Search stopped work due to default trust certificate error

Search doesn't return any result. So checked the ULS log and found out the below error,

Event ID: 8311 An operation failed because the following certificate has validation errors:\n\nSubject Name: CN=SharePoint Security Token Service, OU=SharePoint, O=Microsoft, C=US\nIssuer Name: CN=SharePoint Root Authority, OU=SharePoint, O=Microsoft, C=US\nThumbprint: EB7076586E2CC4A69ED2629497A831D99EB31A1E\n\nErrors:\n\n The root of the certificate chain is not a trusted root authority


Then running the following powershell script to re-issue the certificate and fixed the error.
$rootCert = (Get-SPCertificateAuthority).RootCertificate
New-SPTrustedRootAuthority -Name "localNew" -Certificate $rootCert

 
Restart IIS on all SharePoint servers

Sharepoint trouble shooting - User can not new/edit custom infopath form

There is an error happened when user try to new/edit an list item. This list has been customized using InfoPath form.

So I checked the error log with ULS view and find the critical error below,

The form template failed to load. (.... , Form ID: urn:schemas-microsoft-com:office:infopath:list:-AutoGen-2014-08-20T01:01:56:238Z, Type: COMException, Exception Message: Retrieving the COM class factory for component with CLSID {52F5D46F-CBEA-4D07-BCB7-7296853F0CF2} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).)

This actually because the RichTextBox field is not registered or removed.

So after running the following command to re-register the class, it worked.
regsvr32 "C:\Program Files\Common Files\Microsoft Shared\OFFICE15\htmlchkr.dll"