Thursday, April 28, 2011

Tips and tricks for Site Recycle Bin (Previous Site Deletion Capture) on SharePoint 2010

The Microsoft IT SharePoint 2010 Site Recycle Bin previous named Site Delete Capture tool has been released from CodePlex. It  that has been has been heavily used on SharePoint 2007 and a recommended tool for SharePoint Administrators by the IT Pro community. Most of the functions are identical to previous version and here are some tips and tricks to help you maximize the tool and avoid the pitfalls.

1. How to backup sites created form customized site definition using Recycle Bin tool?
By default this tool will only backup sites created form default Microsoft site templates. If you have sites created from customized site definitions, you need to staple both web and site scope features to ALL site definitions. If you add the following two line, ALL sites created from site definition will be captured.
  •  Goto 14 hive 14\TEMPLATE\FEATURES\SiteRecycleBinDeleteFeatureStapling open FeatureStapling.xml file and add the below entry
   <FeatureSiteTemplateAssociation Id="78B263D4-FF62-415e-B609-F01B06FA54E0" TemplateName="GLOBAL" />
  • Goto 14 hive 14\TEMPLATE\FEATURES\SiteRecycleBinSiteFeatureStapling\FeatureStapling and open FeatureStapling.xml file and add the below entry
   <FeatureSiteTemplateAssociation Id="78B94E15-23CE-43f9-8036-BABD847497D1" TemplateName="GLOBAL" />

2. How can we backup the sites already existing on SharePoint 2010 before the Recycle Bin tool installed?

You do not need to do anything. By default the deployment of this solution will activate the site feature and site collection on ALL existing sites on the farm. Here are the powershell command.

Install-SPSolution -Identity "SharePoint Site Recycle Bin.wsp" -GACDeployment
install-SPFeature -path "SiteRecycleBinSiteFeatureStapling\feature.xml" -force -confirm: $false  
install-SPFeature -path "SiteRecycleBinDeleteFeatureStapling\feature.xml" -force -confirm: $false 

As a result, you do not need to manually enable the features to make it affective. Cool!

3. Will Recycle Bin tool backup sites created form Fab 40 templates?
Yes. 2007 version described previously will not backup Fab 40 sites. However, new version will backup fab 40 sites as long as you add GLOBAL template in the feature stapling as described in #1. We have tested it with 12 different templates that were deployed as wsp on 2010.

4. Will Recycle Bin tool backup sub sites created form sandbox solution templates?
Unfortunately, this tool will NOT backup any sub sites created form templates user saved to templates and then uploaded to the solution gallery. When you check the site created from the saved template, features are activated and the site could be backed up using backup stsadm or powershell. It seems like this is the limitation for this tool. You could refer other blog on the ways to create sites using saved templates.

5.  Will Recycle Bin tool backup sub sites created form farm site templates?
As we described before, you could save the site to a template and deploy it to different farm as global farm based site template. So far so good. However, we found that the sites crated from this type of template could NOT be backed up by Site Recycle Bin. As a result, there is a risk those sites will not be easily recovered.

This is same as item #4, when you check the site created from the saved template, features are activated and the site could be backed up using backup stsadm or powershell.

6. Can we restore the site into the same content DB?
One of my college tested this and confirmed you could not backup the original site into the same content DB where site got deleted. You should be aware this when you backup the site.

7. What is Recycle Bin Backup Share size you should prepare
The answer depends on the governance policy and the SharePoint usage. You should answer the following questions before making the decision.
  • Size of active used sites and growth rate
  • Frequency of users will delete the site collection or sites based on previous experience
  • Size of the each site collections you setup that is depends on your quota setup
  • How long will backup the deleted sites
By answering these questions based on company's policy if there is any, you could calculate the necessary size needed. In normal case, we setup small size and monitor the deleted site.

8. How to resolve "The security validation for this page is invalid Microsoft.SharePoint.SPException" when activating feature 'SiteRecycleBinSiteFeature'?
Please see solution published in for details.

Since Site Recycle Bin tool is using SharePoint stsadm backup command as internal mechanism to backup the sites, you will restore the site same as stsadm restore. You will noticed everything will keep same except the site collection GUID is different. You could refer to other blogs on the difference between backup/restore and export/import of the sites.

Tuesday, April 26, 2011

“Save Conflict" error when creating list or document library with "List Added Event Handler"

After adding "List Added Event Handler" to our SharePoint 2010 feature to update the list properties after listed created, we run into major issue during any list or document library creation by choosing below templates. The issue is we are getting "Save conflict" unexpected error. It is not consistent but happens much more frequently on “Calendar list”. The following list template will have such issue.
  • Document library
  • Form library
  • Wiki page library
  • Picture Library
  • Reports library
  • Calendar list

Users will get the error as indicated int he screen shot.

The error log is identical to the error people reported.

Microsoft.SharePoint.SPException: Save Conflict
Your changes conflict with those made concurrently by another user. If you want your changes to be applied, click Back in your Web browser, refresh the page, and resubmit your changes.

This is a very typical error occurs in SharePoint 2007 for asynchronous event handler. Due to SharePoint and the event receiver code trying to update the item at the same time. After debugging this issue and working with Microsoft, we have finally resolved it on SharePoint 2010. Here are the three changes you should try.

1.  Disable Event Firing when update the list. Please note this.EnableEventFiring() has been deprecated and the code for SharePoint 2010 is:
     EventFiringEnabled = false; 
     // Business logic here  
     EventFiringEnabled = true;

2. Use new SPWeb object for each list modification. The code should look like this if you apply #1 and #2 roles.

       // Use new SPWeb object for each list modification.
       SPWeb web = null;

       //Disable Event Firing when update the list
       EventFiringEnabled = false;  
       properties.List.ParentWeb.AllowUnsafeUpdates = true;
       web = properties.Web.Site.OpenWeb(properties.Web.ID);
       SPList list = properties.List;
       list.Title = "Correlation Id- Save Conflict error";
       // Other actions to add policy to the list
       // Action to add tagging to the content
       properties.List.ParentWeb.AllowUnsafeUpdates = false;
       EventFiringEnabled = true;

3. If you still have save conflict issues like we did, in SharePoint 2010, we have the option to make these kind of events Synchronous by adding this in the Element.xml file of the event receiver while we are registering it.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">
  <Receivers >

After doing adding these changes, we are able to resolve the issue and enjoy the list event.

Thursday, April 21, 2011

How to resolve (401) Unauthorized error for SharePoint web service call from Infopath Webbased form?

We run into an exception when calling OoB list web services from Infopath Webbased form on SharePoint 2010. The exception is "The remote server returned an error: (401) Unauthorized. The remote server returned an error: (401) Unauthorized."

We have NetScaler as load balance in front of multiple IIS servers and we have VIP setup for the Webapps. Users http://SharePointWebApp. However, if the web service is invoked from each individual server such as from the Infopath Webbased form, it generates exception described above. We had this issue before on SharePoint  2007 over two years ago, I though it would be beneficial to record the solution so we will not forget in the future.

There are many possibilities that could cause (401) Unauthorized error. The two major issues if you are using load balancer with multiple IIS servers and setup the alias or VIP for the webapp are authentication loop back issue and load balancer did not return the local host IP issue. You need to fix both of them in order to make web service calls successfully. Here are the procedure to fix them.

1. Authentication loop back issue
The cause was .net 3.5 sp1 - the fix for me was to add a key to the registry to disable authentication double look up. The way to do it is to set the DisableLoopbackCheck registry entry in the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa registry subkey to 1.

To set the DisableLoopbackCheck registry entry to 1, follow these steps on the client computer:
  • Click Start, click Run, type regedit, and then click OK.
  • Locate and then click the following registry subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
  • Right-click Lsa, point to New, and then click DWORD Value.
  • Type DisableLoopbackCheck, and then press ENTER.
  • Right-click DisableLoopbackCheck, and then click Modify.
  • In the Value data box, type 1, and then click OK.
  • Exit Registry Editor.
  • Restart the computer
You could refer to Microsoft link for details and some other links for such solution. There is another KB article on the loop back issue.

2. Load balancer web service call does not return back to the local server. It seems like the web service call fails if the call initialized from one of the servers behind the Load balancer but pointing to web service using VIP alias.

Here are the steps to find the IPs and fix this.

First, you would need to identify the IP for Webapp VIP alias. If your site URL for the is http://SharePointWebApp, you could identify the IP for it from the IIS server using the command and the IP is 22.44.555.66.

C:\ >ping SharePointWebApp
Pinging [22.44.555.66] with 32 bytes of data:
Reply from 22.44.555.66: bytes=32 time=1ms TTL=255

Second, find the IP for the IIS server behind the load balancer using the command ipconfig like below and the IP is

C:\Users\osstst1>ipconfig /all
Windows IP Configuration
   Host Name . . . . . . . . . . . . : xxxxxxxxx
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Peer-Peer
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . :

   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . :

Third, you added one line entry into host file that is located at C:\Windows\System32\drivers\etc\host. Add one additional line like:       SharePointWebApp

Forth, you flush the DNS Resolver Cache using command and verify the WebApp VIP IP original value 22.44.555.66 returned by ping that will changed to local IIS server IP that is
C:\>ipconfig /flushdns 
C:\ >ping SharePointWebApp
Pinging [] with 32 bytes of data:
Reply from 22.44.555.66: bytes=32 time=1ms TTL=255

Now, the web service called by Infopath Webbased form on SharePointIIS server will not go back to the load balancer. It will call web service hosted by the same host server.

By changing these two settings, you should be able to resolve (401) Unauthorized error.

Good luck.

Why SharePoint 2010 search does not show some results?

SharePoint 2010 search is better than ever before. Enterprise search for SharePoint 2010 contains all the features and functionality of MOSS 2007 Search, like people search, but goes further with richer navigation, refinement and related search capabilities. After Microsoft acquired FAST 2 years ago and applied this to SharePoint, it now offers as a separate add-on to SharePoint for those willing to invest in high end enterprise search.

Since search is very comportment in SharePoint adoption, there are many cases users reported they could not find the expected items in the search result. I would like to share the tips we found since August 2010 so you could explain and resolve those "issues" quickly.

Before we dig into some specific search "issues", first you should take a look of the different SharePoint Versions Search Comparison before implement it in your company. Searches like People Search, Social, Taxonomy integration not included in Search Server 2010 Express. Second, verify search services have been setup and associated with webapp and crawling process has been completed without errors. Incremental  crawling process has also been scheduled. You could verify from central admin and refer some instructions. Now let's dig into some specific search "issues" users reported frequently.

1. Why documents or items did not displayed in my search result while is for some other people? This is very common questions people complain and most of the cases, it's the permission issue. Specific users may not have permission to read those documents and as a result, it will not be displayed in the search result.

2. Why documents on one site do not show in the search result but others shown?
Besides the permission checking, this is typical site search disabled setting issue. Go to "Site Actions"->"Site Settings"->Site Administration"->"Search and offline availability" to verify "Allow this site to appear in search results" is set to yes as shown in the screen shot. This is site setting and site owners could hide the items on the site intentionally not to display in the search result.

3. Why search not showing any results for anonymous users?
This is similar site search disabled setting issue described above and you could change site setting and set "Always index all Web Parts on this site" to true.

4. Why some of my documents did not show in the search result?
Yes, this happens to several users and this may be related to Draft documents that are in document library that requires approval. You could check whether your document library enabled the approval process by going to "Document Library Settings"->"Version Settings" and whether "Require content approval for submitted items?" is set to yes as in the screen shots.

There is another interesting setting on the Document Library setting "Draft Item Security" that will impacting your search result.

Here is the case if you have file 1 has version 1.0 that is in published status and version 1.1 checked-in but not approved.

If  "Draft Item Security"is set to "Only users who can edit items", file 1 will NOT in any search result as designed since the crawling process will only index the latest version. In this case, the latest version has not been published and as a result, this file will not be indexed and will not in search result.

However, people reported if "Draft Item Security" is set to "Any user who can read items", file 1 with version 1.0 is still in the index and will be displayed in the search result. However, my testing does NOT display this file in the search result that is consistent with the golden rule - only latest published version will be indexed and if latest version is in draft version, none of the versions will be indexed as designed.

4. Why PDF files not show in the search result?
This is easy answer. You need to install PDF iFilter to index PDF files. You could follow Microsoft instruction to install it.

5.  Why social tagging and discussion not show in the result?
You may check whether jobs to index the social tagging are running correctly. The job for this is scheduled hourly and you could change it from central admin as administrator. The job is named as "User Profile Service - Social Data Maintenance Job" that is to Aggregates social tags and ratings and cleans the social data change log.

6. Why people search not show any result?
Besides you need to have check whether you are NOT running Search Server 2010 Express, this may be the mysite search index issue. You should included the MySite in the index content as in the screen shot. You may refer the instruction listed in some bog and verify it.

7. Why no result show in the default simple search but show in advanced search?
If you can see your items in advanced search but not in default simple search, this might be the webapp zone setting bug described in MSDN discussion board we identified during testing. If you have multiple zones setup for the same webapp. Please mask sure the default zone is Intranet NOT other settings. This seems to be a bug you could not get search result if the default zone is NOT Intranet. We may need to submit this bug to Microsoft.

8. Why my external line of business data not show in the result even we have BCS setup already?
If you have setup BCS to bring external data to SharePoint through external content type and did not find those in search result, this might be the search setting issue. You could configure this in SharePoint Central Administration as described in previous blog.

9. Why documents or items did not displayed in my search result even I have the permission through SharePoint?
If you have implemeted some security policy like NextLabs and enabled Search Result Trimming, it will allows SharePoint to limit the display of search results to only those web parts or documents (i.e., list items) which the search user is authorized to view based on NextLabs entitlement policy. On the worlds, even users have been granted permission through SharePoint to have access those contents, they will not be able to see in search result if thay are restricted from NextLabs policy entitlement. This is one of the requirement from our security team to block groups to access the sesitive content. See my new blog for details.

There are some other search issues we may share later.

Tuesday, April 19, 2011

Risk to install Microsoft Office Web Apps for SharePoint 2010

Microsoft Office Web Apps is the online companion to Office Word, Excel, PowerPoint and OneNote applications that enables users to access documents from anywhere. Users can view, share, and work on documents with other users online across personal computers, mobile telephones, and the Web. Office Web Apps is available to users through Windows Live and to business customers with Microsoft Office 2010 volume licensing and document management solutions that are based on Microsoft SharePoint 2010 Products. You could find the installation with architecture design.

This feature is very helpful if you have SharePoint users accessing Microsoft office documents from UNIX and Linus systems without Microsoft Office client installed.
There is a big risk if you plan to install this to SharePoint 2010.  Our experience was that if an installation of Office Web Apps had to be uninstalled, the result would be that the server would be removed from the farm.  We experienced this with several environments in November 2010 and notified Microsoft.  Microsoft Product team confirmed on April 14, 2011 that the results we experienced are, by design, the correct behavior.  The explanation is that the Office Web Application service must be installed on all web servers and must stay in synch across those servers.  Therefore, to avoid a situation where the servers are not synched, the uninstall process removes the server from the farm.  

Microsoft mentioned this will not be resolved in the near term and may not in next SharePoint version (2015?). Microsoft offered a couple of work-arounds. Microsoft will send us a white-paper detailing those work-arounds. One of the work around is to disable Office Web Apps if installation failed. However,  the high risk is three is no clear procedure Office Web Apps could be upgraded to future version whence this issue been fixed.

The bottom line is that we consider the uninstall process and the work-arounds to be unacceptable risks to our environments and does not plan to use Office Web Apps in our SharePoint environments until an alternative low-risk uninstall process is provided by Microsoft.

Monday, April 18, 2011

SharePoint 2010 users missing pictures in SharePoint groups

We have found many SharePoint 2010 users do not have their pictures when they are added to local groups. Here is the common symptom with detailed description.

1.    Issue - User missing pictures in SharePoint
Picture  not  displayed when  user is added to a any SharePoint group (Members, Owners, Visitors etc. ) of a  SharePoint 2010 site.

2.    Description
When a user is added to any SharePoint group,  the picture does not show.
However,  Mysite has all 3 sizes of pictures (L,M,S) stored in  /User Photos/Profile Pictures/ . Attached are the organizational view of users. Each user has 3 sizes of pictures. My Organization also shows the correct pictures for those people.

The following screen shot shows properties of working picture where url is picked from mysite medium size picture(http://mysite/User%20Photos/Profile%20Pictures/na_harryc_MThumb.jpg).

The second screen shot shows properties of missing picture where url is pointing to person.gif picture(http://projects/_layouts/images/person.jpg). Please note projects is the webapp alias VIP where the site is located.

If you explicitly pasted the medium size mysite picture url of missing picture user in browser(http://mysite/User%20Photos/Profile%20Pictures/domain_userid_MThumb.jpg) , picture is displayed correctly. We could display users' organization with all pictures also. However, the SharePoint group seems not able to associate the users pictures with users.

3.    Procedure to Reproduce
  • Open any SharePoint site in browser
  • Navigate to site actions > site settings> people and groups
  • Add new user to any SharePoint group
  • Picture of a  user is not displayed
4.    Similar issues reported
You could find some people also reported this issue.
We have some other reasons that could cause picture missing issues. Here is the partial list.
  • Users do not have picture in AD
  • Pictures not synced to AD
  • Picture not slitted into three sizes.
    Today (4/19/2011) I just found two jobs that might related to this issue. We may have to take a look of the job status.
    •  User Profile to SharePoint Full Synchronization (Hourly) - Synchronizes user information from the user profile application to SharePoint users and synchronizes site memberships from SharePoint to the user profile application.
    • User Profile to SharePoint Quick Synchronization (5 minutes) - Synchronizes user information from the user profile application to SharePoint users who were recently added to a site.
    One update from Microsoft on May 6, 2011 is that this issue also reported by other customer and it may be fixed by Dec. CU. I may try to apply 2011 April CU and test it again.

    Please let me know if you know how to debug or fix this issue.

    Friday, April 15, 2011

    SharePoint 2010 RSS Viewer Web Part Issues and Tips to display SharePoint list

    After upgraded all SharePoint 2007 to 2010 in August 201, our users are excited to explore some new features and enhanced web parts. One of the enhanced web part listed in 2010 is RSS feed web part. It's quite simple when you display external public RSS feed. You just need to provide the URL to config the web part. However, there are several tricks you should be aware of before you could configure it if you need to feed SharePoint list into the web part. We are facing several issues and many people also reported some strange behaviors.

    The first trick for RSS feed web part is you should change authentication provider settings from NTLM to Kerberos with AD SPN setup if you need to display any SharePoint list as RSS feed. You do NOT need to setup Kerberos if you just need to display external public RSS feed such as The way to setup is straight forward and have not changed since SharePoint 2007. You could check from central admin on each webapp as described here. I noticed if you do not setup AD SPN, the webpart is still not working. Here are the procedures to check whether Kerberosis in deed working for the webapp.

    Check SPN setup using command setspn -l domain\installaccount. Here is the example output from the command. You should see three entries on the server and fully qualified name.

    C:\>setspn -l na\installaccount
    Registered ServicePrincipalNames for CN=,OU=CORP,OU=Service Accounts,DC=domian,DC=company,DC=com:

    In order to confirm the user is indeed login using Kerberos, you could open the Security logs and filter for “Event ID: 4624”. You will see Kerberos as Authentication Package. More details in the future if you are interested in this topic.

    The second trick is you only need to setup Kerberos on the site that is using RSS feed webpart. The displayed site does not need to be Kerberos enabled. I have the screen shot below that has three RSS feed web parts. As long as the web part site is Kerberos enabled, it can display both Kerberos enabled or NTLM enabled site lists.

    The third trick or issue is I'm not able to setup to auto refresh the web part with the latest feeds. It is still same as 2007 that it only refresh after IISRESET! I'm able to find the AJAX options and setup to enable Asynchronous Automatic Refresh and Update as in the below screen shot. However, the web part displayed error "An unexpected error occured while rendering the webpart.". There is even an typo in the error message!

    As of today August 30, Microsoft has provided a workaround to refresh this webpart. Pleas refer to here for details on the workaround.

    The fourth issue is I'm not able to display the feed across the farms. See previous third RSS feed web part. I'm getting error "The RSS webpart does not support authenticated feeds." that is same as you have not setup Kerberos.

    There are some other issues you may encounter fro external RSS feeds with SSL and different sources. We have noticed people mentioned they could display feed across farm we will continue to debug.
    Finally Microsoft confirmed this is not support to auto feed refresh to display SharePoint lists. However, we have identified a workaround that could refresh the webpart even it's not using Ajax. Please refer the workaround and let me know how it works.

    If you have error "The RSS webpart does not support authenticated feeds." on SharePoint 2013 on-premises, you might need to sett the aspnet:AllowAnonymousImpersonation to false in web.config as Brandon mentioned. I would be cautious to change it before complete testing for other webparts especially Access apps, any BCS webparts, and custom webparts using security token.

    If you try to display SharePoint online O365 RSS feed from on-premises even after you configure the trust, you will still get error like 'ProtocolError occurred trying to complete the request. The server returned a status code of : Forbidden and the status description is : "Forbidden"'. I will do more research how we can configure this.

    Thursday, April 14, 2011

    How to enable SharePoint 2010 Web Analytics "Custom Report"

    After we evaluated and put the design together to enable SharePoint 2010 web analytics reports in November 2010 as described in previous blog, we have seen many power users try to use the reports. However, we have identified several issues that is preventing end users to get meaningful reports.

    The first mystery to us is SharePoint 2010 provides a "Custom Report" users could schedule to generate the customized reports based on users criteria.  However some site collection reports such as "Top Pages" is missing "Custom Report" button on the ribbon. We have identified this is only happening on some sites for some environments not all sites. You could refer the two pictures with and without "Custom Report" button. listed in previous bog.

    While debugging this inconsistent issue across different environments and different sites, we have finally identified the issue. Here is the summary of root cause, procedure to verify, and command to to fix it.

    1. Root cause: The root cause is there is hidden site feature named WACustomReports needs to be enabled in order for users to see "Custom Report" button. You could check this from 14 hive directory
    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\WACustomReports.

    <Feature  Id="AF6D9AEC-7C38-4dda-997F-CC1DDBB87C92"
              ReceiverAssembly="Microsoft.Office.Server.WebAnalytics.UI, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

     2. Procedure to check. You could use the following powershell commend to verify whether you have this feature enabled on site collection.

    Get-SPFeature -Site http://sitecollectionurl

    If you have the feature enabled, you will see the following entry.
    DisplayName                                               Id                                              Scope
    -----------                                                   --                                               -----
    WACustomReports                af6d9aec-7c38-4dda-997f-cc1ddbb87c92     Site

    3. Commend to fix this if not already activated. Here is the commend to enable this feature so users could have the "Custom Report" button.

    Enable-SPFEATURE WACustomReports –URL http://sitecollectionURL

    Now you should have the "Custom Report" you could enjoy to use. We were working with Microsoft how we could enable this for all sites automatically. There is a thread on this already from MSDN.

    I looked at issue again this week  April 26 2011, I realized that this feature is automatically enabled for sites created from OoB site definition. However, if you have your own site definition or template, you need to add this feature to the feature stapling to enable it after site created.

    Wednesday, April 6, 2011

    How to deploy saved site template in different SharePoint 2010 farm

    As you know we could utilize the web template created by saving the site as template on SharePoint 2010. The use case listed here is that use created a site on their non-production SharePoint 2010 farm and saved as template. Use requested IT to help so other users could create site collections based on this template in production farm.

    The way how to deploy this saved template for reuse is described before. The major issue left is site creation will fail if the features are not exactly same on the destination farm with template farm the template created from. There is a chance the non-production development SharePoint 2010 environment may have different features than production. When developers are testing this on their development box, they may not have all features developed to production either. How we could package the solution described in previous blog so it can be deployed and used successfully in the targeted SharePoint farm?

    In SharePoint 2007, there is a tool STPInspector we could use to identify the mismatching features and repackage the stp file before the deployment. However, this tool no longer working against SharePoint 2010 wsp template. Someone will definite develop this tool shortly. At meantime, here are the way you could do to package the solution described in previous blog to a potable solution to avoid mismatching features.

    • Create a site collection on destination SharePoint farm such as production environment using the same template such as “Team Site” user using to create the previous site.
    • Save this template as template wsp file.
    • Import this first wsp file from destination SharePoint farm into your visual studio  as described in previous blog.
    • Open the ONet.xml file and find the site and web features from the <Configurations> tag.
    • Import user wsp file from source SharePoint farm into your visual studio  as described in previous blog.
    • Compare and replace the site and web features from the <Configurations> tag.
    • Repackage the solution and change the scope as described in previous blog.
    • You could deploy this to destination farm and create site collections based on this template without missing features error.
     Here is the partial of the ONet.xml for your reference.

            <Configuration ID="0" Name="Default" MasterUrl="_catalogs/masterpage/QualcommMasterElements/Qualcomm.master" ThemedCssFolderUrl="">
                    <!--DocumentRoutingResources Feature-->
                    <Feature ID="{0c8a9a47-22a9-4798-82f1-00e62a96006e}" Name="FeatureDefinition/0c8a9a47-22a9-4798-82f1-00e62a96006e" SourceVersion="" />
                    <!--EnhancedTheming Feature-->
                    <Feature ID="{068bc832-4951-11dc-8314-0800200c9a66}" Name="FeatureDefinition/068bc832-4951-11dc-8314-0800200c9a66" SourceVersion="" />
                    <!--Ratings Feature-->
                    <Feature ID="{915c240e-a6cc-49b8-8b2c-0bff8b553ed3}" Name="FeatureDefinition/915c240e-a6cc-49b8-8b2c-0bff8b553ed3" SourceVersion="" />
                    <!--WebPartAdderGroups Feature-->
                    <Feature ID="{2ed1c45e-a73b-4779-ae81-1524e4de467a}" Name="FeatureDefinition/2ed1c45e-a73b-4779-ae81-1524e4de467a" SourceVersion="" />
                    <!--Other Feature -->               
                    <!--WikiPageHomePage Feature-->
                    <Feature ID="{00bfea71-d8fe-4fec-8dad-01c19a6e4053}" Name="FeatureDefinition/00bfea71-d8fe-4fec-8dad-01c19a6e4053" SourceVersion="">
                            <Property Key="OldWelcomePage" Value="" />
                    <!--WebPageLibrary Feature-->
                    <Feature ID="{00bfea71-c796-4402-9f2f-0eb9a6e71b18}" Name="FeatureDefinition/00bfea71-c796-4402-9f2f-0eb9a6e71b18" SourceVersion="" />
                    <!—Other features-->

    If you want to list the features on Farm, Site Collection and Site before you repackage the wsp file, you could use the powershell the discrepancy of the feature on different farms.

    To see all features for a Site Collection:
    • Get-SPFeature -Site http://sitecollection
    To see all features for a Site:
    • Get-SPFeature -Web http://siteurl

    You could check features on farm and webapp using commands posted.

    Now, you got the idea how to repackage the saved template so it can be deployed and used on different SharePoint farm.

    There one issue on the sites created from such site template - the sites could NOT be backed up using Site Recycle Bin tool (Previous Site Deletion Capture) on SharePoint 2010 just discovered. I have described in the another blog

    Friday, April 1, 2011

    How to save a site template and use it is the farm to create site collections and sub sites in 2010

    In 2007 when you wanted to create a new Site Collection with a template saved from a site, the site template needed to be installed globally before it could be utilized. The command to  do this are:

           // Add template to the global gallery so you could use any where
           stsadm -o addtemplate -filename Regions.stp -title Regions

          // You could check the template availability
          stsadm -o enumtemplates

    Of case there are several major issues associated such as feature compatibility across environment and workflow will not working if save template with content. Of cause we have identified workarounds already last year to resolve those issues. I’m not a fun of site template and prefer to use site definition sue to the better maintainability.

    SharePoint 2010 is little different and there are many ways to implement reusable templates.  To be specific using site template inn 2010, you can choose to load a site template to create sub sites or site collection at creation time. Here are two major use cases.

    1.    The most user cases are using saved template as sandbox solution gallery in the solution to create sub site. The default wsp file saved is web scope and sandbox solution anyway. You could refer this blog on the procedure. It’s quite simple and I will not explain this in the blog.

    2.    The second use case is users wants this template available to create site collection from site collection. In additional this template should be available globally to be provisioned by auto-provisioning tool such as SharePoint Site Provisioning and Governance Assistant (SPGA) tool we are using to automate the site creation and approval process.  In order to make it available in central admin when creating the site, there are some options and I’m listing the best option from our implementation to our end users. Again, as I mentioned before, I’m still prefer to use site definition unless we have to use site template sine it save some time.

    There are several options to do this and some of them does not make sense to me and I was totally lost at beginning. You should avoid those if you need to use site template.

    The first way to install template seems like to use powershell command Install-SPWebTemplate. Here are the procedure and issues.

       Command: Install-SPWebTemplate -path "E:/Harry/Temp1.wsp" -name "Temp1" -description "TestWSP" -Confirm:$false

        Error is : Cannot find or parse web template file E:/Harry/Temp1.wsp
        Result: You will not get template installed and I’m not sure what the usage of this powershell usage and could not figure out

    The second way is to deploy the solution using  powershell command Add-SPSolution. Here are the procedure and issues.
       Commands:    Add-SPSolution -LiteralPath " E:/Harry/Temp1.wsp"
                                Install-SPSolution Temp1.wsp –GACDeployment

      Issue is :     Cannot find it from central admin to use for site collection creation
      Workaround:   You have to do some configuration to use it. See the blog for details.

    The third way and I believe the best way inspired by the response from Mirjam’s response is to repackage the wsp using Visual Studio and deploy as farm solution. Here is the way to do this and you have much better control and maintainability. Here are the steps we implemented it.
    1. Create a new SharePoint 2010 project using Visual studio
    2. Selecting “Import SharePoint Solution Package” template
    3. Browse site template WSP file you want to use and select “Deploy this WSP as farm solution” – This is critical to make it available in the farm
    4. Select items you need as site template existed on this WSP to be packaged and click ok
    5. Change the web template feature scope from site to farm so that we can see this template on site collection creation page. Be aware of multiple features and you need to select the right one feature
    6. Add DisplayCategory="MyTemplate" on web template elements.xml file to include this template on your MyTemplate tab
    7. Package this solution and deploy the using Add-SPSolution
    8. Now open the Site collection create page, we can able to see “Temp1” template on MyTemplate tab as shown in below screen shot.

    At this time, you should be able to use this site template to create new site collections or sub sites. However, there is potential issue that may prevent sites to be created successful - feature comparability. Unless you have exact same features installed on the farm as the site you saved as site template, you have have error feature not installed on the farm error when creating sites. I'll address this issue in later blog.

    There is another issue on the sites created from such site template - the sites could NOT be backed up using Site Recycle Bin tool (Previous Site Deletion Capture) on SharePoint 2010 just discovered. I have described in the another blog