Clean up – Search Service Application in SharePoint 2013

Well you faced something went wrong and looks that you could not able to delete search service Application correctly. In this article’s purpose  demonstrate which components we have using for a Search Service Application

Ok Lets break our Search Service Application .Well don’t try this on a production 🙂 I assume that you have a completely running Search Service Application and will break it to test purpose
Open a sharepoint powershell console and type

$SSA = Get-SPEnterpriseSearchServiceApplication
(if you have more than one SSA you need to change parameters to get the correct one)
CleanSSA1

So lets create a scenario that someone we assume has deleted our good SSA like

$SSA.Delete()

CleanSSA2

+Upps In this condition you have a big problem. Because deleting the object of the service app itself is not a correct action . It clears the Service Application Object but Search Service Application have many other components (IIS Web Service,Timer Jobs ,DBs etc)  and they are still remains. Unfortunately there is no warning when you did it.
If you really want to remove a Service Application , you have to use Remove-SPServiceApplication cmdlet, not call the related object’s delete method.

So define what is remaining we have to know what components are we installing when you provision a Search Service Application

-We have creating a IIS Web Site under SharePoint Web Services Site.
-We have creating 8 Timer jobs for every SSA.

  • “Search Custom Dictionaries Update for Search Application <guid of SSA>”
  • “Crawl Log Cleanup for Search Application <guid of SSA>”
  • “Rebalance crawl store partitions for <guid of SSA>”
  • “Usage Analytics Timer Job for Search Application <guid of SSA>”
  • “Spelling Customizations Upgrade for Search Application <guid of SSA>”
  • “Spelling Dictionary Update for Search Application <guid of SSA>”
  • “Analytics Timer Job for Search Service Application <guid of SSA>”
  • “Query Classification Dictionary Update for Search Application <guid of SSA>”

-In a usual way we have creating a Search Service Application Proxy
-And that Proxy consumed by several Web Applications .
-And a Search Administration Web Service (We are using this for Crawl operation, Crawl component is not a FAST Search related part and not runs under noderunner.exe process .

Actions:
Well the supported action for this scenario is return from Backup by Microsoft!
But if you want to get a clean state on a test env you may try this;

1) Remove the Search Service DB’s
CleanSSA3
2) Open IIS and find Search Service Related web sites under SharePoint Web Services , locate and delete only the related search service site.
CleanSSA6
3) Clean up all SSA Connections on Web Application level.
-Open the Central Administration -> Manage Web Application -> Select Web Application -> Click to Service Connections on the ribbon
CleanSSA5
4) Remove if SSA Proxy still available
CleanSSA4
5) Remove Search Administration Web Service Application if exists

6) Clear the timer jobs belong to deleted SSA .(Otherwise they will make a log noise with critical exceptions )
(I accept this can create some concequences and you may not able to delete some remaining timer-jobs very easily in some scenarios but at least you can disable them.)
Well totally clear it , you may need to open a case to Microsoft.

Even so there are many objects still remains in SharePoint_Config database. Directly deleting from database is an unsupported operation!

 

Advertisements

Microsoft.Workflow.Client.AuthenticationException “Authentication Failed”

When attempting to publish a workflow in SharePoint 2013 . you may facing following problem.

System.InvalidOperationException: Operation failed with error Microsoft.Workflow.Client.AuthenticationException: Authentication Failed. Valid credentials must be provided for one of the following protocols: Bearer, Negotiate. HTTP headers received from the server – ActivityId: 440bd264-3528-4880-91c9-03247a2e5e10. NodeId: WFSERVER01. Scope: /SharePoint/default/e72269ca-0e8c-4bd6-800a-9499da19f233. WWW-Authenticate: Bearer realm=”22a5da47-566b-4e0b-90f9-76752903b68e”, client_id=”00000005-0000-000

TroubleShooting Steps
1) First you have to check installation and upgrades:
It is important that any Cumulative Updates (CU) for SharePoint Server 2013 and Workflow Manager are installed in a coordinated fashion. After an update has been performed, several Windows PowerShell cmdlets must be run in order to maintain the connection between the SharePoint Server 2013 farm and the Workflow Manager farm.
Check that you have Service Bus 1.1
Check that you have Workflow Manager 1.0 Refresh installed
Check that you have Workflow Manager 1.0 Refresh Client (must installed all SharePoint Servers)
Check that you have at least SharePoint 2013 SP1.
(Article Date: 24/12/2014)

If you want to use Workflows with Microsoft supportability you need to have latest bits is running.

2) Check Network connections. (Dont miss this step is very important , Even Some Scenarios it looks working while you can save workflows and Worflow Manager Service looks connected but this issue can happen)
SharePoint Servers (WFEs) must able to reach Workflow Manager web site
And also it is a requirement that from Worflow Manager Machine (if it is a different machine) must able to browse the site url which you use to register-spworkflowservice.
Ping both machines that have ip communication
And also Check Proxies

3) Check all host file entries on every server that is there something preventing network communication .

4) Check Firewall rules and communications.

5) Test your credentials are correct or not .

7) Check Workflow Services are running , Workflow Manager Web Site is up and Application pool is alive.

8) If workflow manager is hosted on a different machine check IIS configuration that you have Windows Authentication is enabled.

9) Try re-register workflow service by scopename;
Register-SPWorkflowService -SPSite ‘http://mywebsite&#8217; -WorkflowHostUri ‘https://workflowhost&#8217; -AllowOAuthHttp -scopename “SharePoint”  -Force

10) If it doesnt work ; unregister the Workflow manager from the sharepoint farm
Get-SPWorkflowServiceApplicationProxy | Remove-SPServiceApplicationProxy
and run
Register-SPWorkflowService -SPSite ‘http://mywebsite&#8217; -WorkflowHostUri ‘https://workflowhost&#8217; -AllowOAuthHttp -scopename “SharePoint”  -Force
this will recreate the SPWorkflowServiceApplication Proxy.

(Dont Forget make an iisreset after use “Register-SPWorkflowService”)

11) Verify you have using latest activities are updated through the Workflow Manager.

$credential = [System.Net.CredentialCache]::DefaultNetworkCredentials
$site = Get-SPSite(<siteUri>)
$proxy = Get-SPWorkflowServiceApplicationProxy
$svcAddress = $proxy.GetWorkflowServiceAddress($site)
Copy-SPActivitiesToWorkflowService -WorkflowServiceAddress $svcAddress -Credential $credential -Force $true

Make your test with creating a new workflow and publish.

 

 

 

October 2014 CU for SharePoint has been released

For SharePoint 2010:
http://blogs.technet.com/b/stefan_gossner/archive/2014/10/14/october-2014-cu-for-sharepoint-2010-has-been-released.aspx

For SharePoint 2013:
http://blogs.technet.com/b/stefan_gossner/archive/2014/10/14/october-2014-cu-for-sharepoint-2013-has-been-released.aspx

Open in Explorer view problem for SharePoint 2013 SSL with SNI

Using with SNI with SharePoint 2013 is supported  but wehn you try to use “Open In Explorer View” is not working.
Unfortunately this problem is not related with SharePoint 2013 nor IIS SNI configuration,

It is related with OS WebClient Service do not support SNI on Win7 and Win8.1.

For a Workaround you may try;
http://blogs.technet.com/b/applicationproxyblog/archive/2014/06/19/how-to-support-non-sni-capable-clients-with-web-application-proxy-and-ad-fs-2012-r2.aspx

 

 

few things you should NOT do when deploying Office Web Apps Server

First, here are a few things you should NOT do when deploying Office Web Apps Server.

  • Don’t install any other server applications on the server that’s running Office Web Apps Server. This includes Exchange Server, SharePoint Server, Lync Server, and SQL Server. If you have a shortage of servers, consider running Office Web Apps Server in a virtual machine instance on one of the servers you have.

  • Don’t install any services or roles that depend on the Web Server (IIS) role on port 80, 443, or 809 because Office Web Apps Server periodically removes web applications on these ports.

http://technet.microsoft.com/en-us/library/jj219435%28v=office.15%29.aspx

August 2014 CU for SharePoint 2010/2013 has been released

The product group released the August 2014 Cumulative Update for the SharePoint 2013 product family.

ATTENTION:

Be aware that all Update for SharePoint 2013 require SharePoint Server 2013 SP1 OR March 2013 PU for SharePoint 2013 to be installed first.

Please also have a look at the article that discusses how to properly patch a SharePoint 2013 farm which has Search enabled (see below).

Also be aware that in August no so called “Server” or “Uber” packages have been released instead only fix packages for individual components of SharePoint have been released. That means if your SharePoint system is on an older patch level than July 2014 CU you need to install July 2014 CU before installing the below listed August 2014 CU fixes in order to update your system to the latest patch level.
With other words: It is highly recommended to install SP1 and July 2014 CU before installing August 2014 CU!

Previous releases of the SharePoint Server 2013 cumulative update included both the executable and the .CAB file in the same self-extracting executable download. Because of the file size, the SharePoint Server 2013 package has been divided into several separate downloads. One contains the executable file, while the others contain the CAB file. All are necessary and must be placed in the same folder to successfully install the update. All are available by clicking the same Hotfix Download Available link in the KB article for the release.

This CU does NOT(!) include all SharePoint 2013 fixes previously released! It is recommended to install July 2014 CU before installing this CU.

The CU does not include SP1! You can install SP1 before or after installing this CU.

  • KB 2883081 – SharePoint Foundation 2013 August 2014 CU
  • KB 2883086, KB 2883085, KB 2883078, KB 2880559, KB 2760213 – SharePoint Server 2013 August 2014 CU
  • KB 2883083 – SharePoint Server 2013 with Project Server August 2014 CU
  • KB 2883093 – Office Web Apps Server 2013 August 2014 CU (KB delayed)

 

 

For More Information :
http://blogs.technet.com/b/stefan_gossner/archive/2014/08/13/august-2014-cu-for-sharepoint-2013-has-been-released.aspx

For SharePoint 2010 August 2014 CU

The product group released the August 2014 Cumulative Update for the SharePoint 2010 product family.

Be aware that the August Cumulative Update for SharePoint 2010 is a Post-SP2 hotfix. It is recommended to have SP2 installed before installing the August CU.

Also be aware that in August no so called “Server” or “Uber” packages have been released instead only fix packages for individual components of SharePoint have been released. That means if your SharePoint system is on an older patch level than July 2014 CU you need to install July 2014 CU before installing the below listed August 2014 CU fixes in order to update your system to the latest patch level.
With other words: It is highly recommended to install SP2 and July 2014 CU before installing August 2014 CU!

This CU includes all SharePoint 2010 fixes released since SP1. The CU does not include SP2.

  • KB 2889825 – SharePoint Foundation 2010
  • KB 2889831 – SharePoint Server 2010

 
For More Information:
http://blogs.technet.com/b/stefan_gossner/archive/2014/08/13/august-2014-cu-for-sharepoint-2010-has-been-released.aspx

Unable to delete a content type from a List (TroubleShooting)

I accept that sometimes deleting a content type is a real pain . But it has to be , because if it is still referencing an item , it should not be deleted for preserving data integrity .
In this article I will explain some scenarios and strange conditions  explains why you are not able to delete a content type and how to detect and resolve this problems.

Before starting to explain scenarios  , I would like to give a brief definition that SharePoint how to check an item reference is present or not for a content type in a list .

If you want to delete a contenttype from a document library or list we have a stored procedure named (proc_IsContentTypeInUseInList)  which is resposible to checks all lists items including versions if any reference to old contentype  If that stored procedure finds a version of an item is still referencing the old content-type it prevents the deletion of the content type .

I have created a sample SQLs based on this stored procedure that you can figure out the items still refencing the content types ;

Following query will groups all items in a list  referenced by content type usage.

SELECT tp_ContentTypeId, count(*) FROM
TVF_UserData_List(‘<GUID OF LIST ID’) AS UD
WHERE
‘<GUID OF SITE ID>’= UD.tp_SiteId
Group By tp_ContentTypeId

CTQuery1

Ok. Now you need to find out the IDs for parameters and understand the results .

You can list all content types ids and names by following powershell
$site = get-spsite http://blog.bugrapostaci.com
$web = $site.OpenWeb()
$list = $web[“Shared Documents”]
$list.ContentTypes | ft id,name -Wrap

ShellListContentTypes

Other parameters for the SQL Commands can be reach  like below.

For getting a list id : $list.ID For getting a web id : $web.ID

For getting a site id: $site.ID

OtherParams

 

By following Query you can see all items in a list by given content type id ;

SELECT * FROM
TVF_UserData_List(‘<GUID OF LIST ID>’) AS UD
WHERE
‘<GUID OF SITE ID>’= UD.tp_SiteId
UD.tp_ContentTypeId = <HEX ContentTypeID >

Note: ContentTypeId must not have quots like guids.

CTQuery3

By Following Query you can see all list items in a list .

SELECT * FROM
TVF_UserData_List(‘<GUID OF LIST ID>’) AS UD
WHERE
‘<GUID OF SITE ID>’= UD.tp_SiteId

View1forCTQ2

CTQuery2

As you may notice if we want to delete “Document” Content-type from this library ,( ContentTypeID: 0x01010011D07005A6F3F6419CCC58B996B33DC3)
It is still referencing to item 18.

Scenario 1:  Check-Out

In that scenario we assume that we have a list versioning and approval is not activated
What happens if you Check-Out a document and change its content-type by UI to “HelloContentType”
(ContentTypeID:0x0101000661D1E419F908438CD1787888A9D4F0005A3C0BD18064074BB08DE73AE92D1B24)

*What happens if you have a check out a document  ;

1) SharePoint will create another version (row in database)  until the check-out document be checked-in or discard Check-out
2) Check-out version of record marked in database as Current Version . (tp_IsCurrent =1) -> Tp_CheckoutUserId set WHO is checked-out.
3) tp_UIStringVersion is increased to next majör version.
4) Both for the records tp_IsCurrentVersion set =1

In that scenario you can not delete the “Document” Content Type

******************************

Behaviour for discart-checkout

1) Create a “TestContentType” in Site content types

2) Create a document Library  and added this newly created content type to this library

3) Uploaded a document to this document library which default content-type is “Document”
,( ContentTypeID: 0x01010011D07005A6F3F6419CCC58B996B33DC3)

4) Checked-out this document

5) After checked-out this document i changed the content type as “TestContentType”

6) When i discard the checkout of this document

7) It will revert-back to again “Document” content type

 

So basically ,

 For a document , if it has checked-out we have creating another version of this document even versioning is not enabled until the document checked-in back again .

 If you want to delete a contenttype from a document library we have a stored procedure named (proc_IsContentTypeInUseInList)  which is resposible to checks all lists items including versions if any reference to old contentype . If that stored procedure finds a version of an item is still referencing the old content-type it prevents the deletion of the content type .

Scenario 2: If we have a list previously versioning and approval activated but deactivated now.

Repro Steps

1)      Created document Library

2)      Created and added a new Content Type “HelloContentType” to this library

3)      Add a document by setting “HelloContentType”

4)      Enabled Versioning and Approval

5)      Changed the content-Type as “document” , That caused the item is draft

6)      Disabled the Versioninng and Approval.

 

In browser we see the content type as “Document”  for the record But in content database

We see  as 2 record .

“1.0” version is pointing the “HelloContentType”

“1.1” version is pointing the “Document” Type

In this scenario , in some point, we have a minor version of a document and than we have changing library setting for not use approval and versioning.

if we do this , By design SharePoint will not clear minor document records and it remains.  (Version format as you know “Major.Minor” exp 1.2  ,  1.4  )
(Why ? because what if you did it unintentionally .we able to revert  back)

Again “by design” For all minor versions belong to The Last Major version  are considered “Current Version” that we can see in Database “tp_IsCurrentVersion”  column data set as “1”  and in powershell if we list the versions we can see the last major version’s all minors are considered IsCurrentVersion equals true. (Don’t confuse with “tp_IsCurrent” it is a different column. )

Stored Procedure named “proc_IsContentTypeInUseInList” for checking the list’s items references for content type which we  want to delete . In that procedure we are only validate and retrive the items which are tp_IsCurrentVersion = 1 ; thats mean if we want to delete a content type , The ContentType dependency is not checked for all versions but just for the current item’s Last Major versions .

For example ;

Assume that you have following item versions for an item in a list.

1.0 -> ContentType : TestContentType

1.1->  ContentType : TestContentType

2.0 -> ContentType : TestContentType

2.1 -> ContentType : DocumentContentType

Versions

CTQuery4

As i told the last major version is 2 -> so 2.0 and 2.1 is marked for isCurrentVersion =1

So basically you could not delete the TestContentType because it is refrenced 2.0 version .

For following scenario

1.0 -> ContentType : TestContentType , IsCurrentVersion = 0

1.1->  ContentType : TestContentType, IsCurrentVersion = 0

2.0 -> ContentType : DocumentContentType IsCurrentVersion = 1

2.1 -> ContentType : DocumentContentType IsCurrentVersion = 1

You able to get delete “TestContentType” without any error.

As you may ask what happen if i restore a version like “1.0“ which is refencing “TestContentType” and that content type is already deleted from List.
In that scenario , SharePoint will automatically assign the default content type of the list to this item if you restore “1.0” version .
What happen to data ? you will not be able to see the data for the deleted content type but it has still present in database . If you add the deleted contenttype back to this list.
and change again the item content type to the deleted but added again one , you will see the data still there.

Resolution:

  • If you open this kind of an item (Edit Item Properties)  in SharePoint by Browser and Save again without any change. The Minor version will be overrided by a Major version
  • Or in Powershell you can use  “SPItem.SystemUpdate()” without change anything exp:
    $site = get-spsite http://blog.bugrapostaci.com
    $web = $site.OpenWeb()
    $list = $web.Lists[“<The List Name>”]
    $item = $list.GetItemById(<Item ID>)
    $item.SystemUpdate()

What happen if you do this :   Below record will be marked as IsCurrentVersion = 0

“1.0” version is pointing the “HelloContentType”

This record will be updated “1.1” version is pointing the “Document” Type As “2.0” version is pointing the “Document” Type  -> and marked as Current Version =1 Why because major version changed.

If you have more that one minor version like ;

1.0 -> marked as IsCurrentVersion = 0
1.1 -> marked as IsCurrentVersion = 0
1.2 -> the latest one will be updated; “2.0” version and marked as Current Version

And you are now able to delete the “HelloContentType” without any problem .

Q: Can i change a previous version of an item’s data for example contenttype  ?
 Unfortunately there is no OOB feature that you can change or update data for SPListItemVersion object. It is not permitted by SharePoint design .

 

Scenario 3: If Only Approval is enabled but versioning disabled for a list.

In That scenario , if you change someting on an added item in a list .SharePoint will behave like this.

“1.0” Version Approved “TestContentType” IsCurrentVersion = 1
“2.0” Version Pending “Document” Content Type  IsCurrentVersion=1

So you count not able to delete “TestContentType” because it will be considered as current version until you have to approve the pending one .
When you approved it .
“1.0” will be deleted . and you can delete “TestContentType” without problem .

Scenario 4: Previously  Approval enabled but now is disabled for the list

1) Created document Library
2) Created and added a new Content Type “HelloContentType” to this library
3) Add a document by setting “HelloContentType”
4) Enabled Approval but not versioning.
5) Changed the content-Type as “document” , That caused the item is pending
6) Disabled Approval.

That remains 2 items versions behind.
“1.0” Version Approved “HelloContentType” IsCurrentVersion = 1
“2.0” Version Pending “DocumentContentType” IsCurrentVersion=1

Resolution same;

  • If you open this kind of an item (Edit Item Properties)  in SharePoint by Browser and Save again without any change. The Minor version will be overrided by a Major version
  • Or in Powershell you can use  “SPItem.SystemUpdate()” without change anything exp:
    $site = get-spsite http://blog.bugrapostaci.com
    $web = $site.OpenWeb()
    $list = $web.Lists[“<The List Title>”]
    $item = $list.GetItemById()
    $item.SystemUpdate()

 

Scenario 5:

Assume that you have a library that versioning (Major and Minor) and Approval enabled for this library

  • Unless you create a new approved major version , there is no possible to delete content type for “Current Major Version”’ scope.  Unfortunately this is not possible by SharePoint design.

Exp:
2.0 -> ContentTypeA , Approved ,

2.1 -> ContentTypeB , draft

2.2 -> ContentTypeB , draft

2.3 -> ContentTypeB , dfaft

3.0-> ContentTypeB, Pending -> You can not delete the content type A .

After you approved 3.0
3.0 -> ContentTypeB , Approved .

Now .You can delete the ContentType A. Because the approval provides that all 2 majors will be set as IsCurrentVersion = 0


APPENDIX 1:

How to Change a content-type by powershell

$site = get-spsite http://blog.bugrapostaci.com   #get the site
$web = $site.OpenWeb(“posts”)             #open the SPWeb object
$list = $web[“Shared Documents”]        #Get the library.
$ct = $list.ContentTypes[“Document”]     #Get the content type which we will set for the item
$item = $list.GetItemById(<ITEM ID>)  # Item ID as integer
$item[“ContentTypeId”] = $ct.ID           #set the new content type
$item.SystemUpdate()                               #run systemupdate()

 

APPENDIX 2:
How to see item versions in powershell :

$site = get-spsite http://blog.bugrapostaci.com   #get the site
$web = $site.OpenWeb(“posts”)             #open the SPWeb object
$list = $web[“Shared Documents”]        #Get the library.
$item = $list.GetItemById(<ITEM ID>)  # Item ID as integer
$item.Versions

Unfortunately there is no OOB feature that you can change or update data for SPListItemVersion object. It is not permitted by SharePoint design .

ListItemVersions