Monday, March 12, 2012

PowerShell Solution Deployment Process



Central Admin
Site/Web Level Features
GAC
Web.
Config
14-Root Features
SharePoint Config DB, Objects Table – Solutions
SharePoint Config DB, Objects Table – Features
Web App Content DB, Features Table
Add-
SPSolution
Solution Added but Not Deployed
N/A
N/A
N/A
N/A
Yes – Solution Definition Added
N/A
N/A
Install-SPSolution
Deployed to Web App
Installed Feature
Yes – DLLs Added
Yes – 
Safe 
Control Entries Added
Yes – Features Added
Yes – Solution Definition Still Exists
Yes – Feature Definition Added
N/A
Enable-SPFeature
Solution Still Deployed
Activated feature to Site/Web
Yes – Still Exists
Yes – Still Exists
Yes – Still Exists
Yes – Solution Definition Still Exists
Yes – Feature Definition 
Still Exists
YES – Feature Activation Link Added
Disable-SPFeature
Solution Still Deployed
Deactivated feature from Site/Web
Yes – Still Exists
Yes – Still Exists
Yes – Still Exists
Yes – Solution Definition Still Exists
Yes – Feature Definition 
Still Exists
NO – Feature Activation Link Deleted
UnInstall-SPFeature
Solution Still Deployed
Uninstalled feature
Yes – Still Exists
Yes – Still Exists
Yes – Still Exists
Yes – Solution Definition Still Exists
No – 
Feature Definition Deleted
N/A
UnInstall-SPSolution
Retracted from Web App
Uninstalled feature
No – DLLs Deleted
No – Safe Control Entries Deleted
No – Features Deleted
Yes – Solution Definition Still Exists
No – 
Feature Definition Deleted
N/A
Remove-SPSolution
Solution Deleted
N/A
N/A
N/A
N/A
Yes – Solution Definition Deleted
N/A
N/A

SharePoint Search Errors


Error1:
Access is denied. Verify that either the Default Content Access Account has access to this repository, or add a crawl rule to crawl this repository. If the repository being crawled is a SharePoint
repository, verify that the account you are using has "Full Read" permissions on the SharePoint Web Application being crawled.( http://samcommunity.qxl.int , http://bpsmerfwwf.qxl.int and http://marketing.qxl.int:8080 )

Reason:

This error will occur, at the time of crawling the SharePoint application content. because, you may have provided a URL to access the SharePoint web application like http://portal.com.au(just an example). If you try http://portal.com.au from the server, you will find you cannot access it at all.

When the search engine tried to crawl the content using the kenportal.com.au URL, the server will reject the request. because, it will take the request as "LoopBackRequest".

Work around:

So we need to disable the LoopBackRequest in registry.

Steps:

1. Go to command window and type regedit.exe

2. Once opened the registry editor, just navigate to "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa"

3. Right click on "Lsa" and create a new 32bit DWORD value

4. Rename it as "DisableLoopbackCheck" (Note: you cannot rename it actually. so, once created the DWORD value, directly paste/type as "DisableLoopbackCheck".

5. Then again modify the value of "DisableLoopbackCheck" as "1"
6. Close the registry editor.
7. Now start to crawl the content.


Error2:

This item could not be crawled because the crawler could not connect to the repository.

Suspecting this  issue  from the network firewall side, we need to make sure that all the required ports are opened.



Error3:

The object was not found.( http://us-bos-vwb012  and sps3://us-bos-vwb012)

In our case the object is  http://us-bos-vwb012/   and is not have the  root site. i.e. reason we got the object was not found in the crawl error .


Observations from  Dev Environment  :

Configured the Search functionality for testing purpose  in Dev and  Is working  for  these  sites :



In Dev Env also got the same error (Error1:  Access is denied. Verify that either the Default Content Access Account has access to this repository, or add a crawl rule to crawl this repository.)

Executed the  above workaround (to disable the LoopBackRequest in registry) and  ran the full crawl. after that the Access Denied error resolved in Dev Env.

And from the best practice and security reasons we need to go for a separate Search managed service account to read and crawl  the content in our SharePoint Portal.






Solution / Feature Scopes in SharePoint 2010


A feature should be reusable component which can be activated anywhere once deployed .The feature definition has two interesting attributes: Scope and Hidden.

Scope can be Web, Site, Web Application or Farm. It explains why a given feature is visible in the site settings page for a site, a site collection or in central admin .Hidden can be True or False. Only when the value is True is the feature visible in any admin screen.

If we really want to keep things from being exposed to others(Site Owners),  will most likely need to deploy these features as hidden features and then activate them from the command line for the people who need them.

i.e. Hide it and use powershell or stsadm script to deploy.

Sample Ex:

Feature.xml

          Title="Widget Data Site Columns"
          Description="Installs columns designed to manage information about widgets."
Hidden=”True”          Version="12.0.0.0"
          Hidden=”FALSE”
          Scope="Site"
          DefaultResourceFile="core"
          xmlns="http://schemas.microsoft.com/sharepoint/">
   
       
   


The Hidden attribute setting specifies whether the Feature is visible in the list of Features on the Site Features web page. Here, the attribute is set to TRUE which makes the Feature visible to users who want to activate it.

SharePoint Element Types for Features:
The following table describes various element types for Features and shows their possible settings for scope.
Element
Description
Scope
Content Type
Contains a schema definition you can reuse and apply to multiple list definitions.
Site
Content Type Binding
Content type binding enables you to provision a content type on a list defined in the Onet.xml schema. Lists defined in the Onet.xml schema cannot be modified directly.
Site
Control
A delegate control contains a registration for a well-known control installed on a Web page. This lets you replace existing controls, such as the Windows SharePoint Services search control, with another control.
Farm
Web
Application,
 Site 
Web
Custom Action
You can define the following kinds of custom actions:
·         Content type links for the content type settings page
·         Drop-down menu actions for the drop-down menu that appears for an item
·         Form toolbar buttons for New, Edit, or Display form toolbars.
·         Site Settings link for the Site Settings page.
Farm,  
Web
Application,  
Site 
Web
Custom Action Group
Defines a group of custom actions.
Farm,  
Web
Application,
 Site,
 Web
Document Converter
Contains the definition of a document converter. A document converter is a custom executable file that takes a document of one file type, and generates a copy of that file in another file type.
Web
Application
Feature/Site Template Association
Binds a Feature to a site definition configuration so that created sites are provisioned with the Feature.
Farm
Web
Application
 Site
Field
Contains a field definition that can be reused among multiple lists.
Site
Hide Custom Action
Hides a custom action that has been added through another custom action.
Farm
Web
Application,  
Site,
 Web
List Instance
Provisions a SharePoint site with a specific list of data.
Site,
 Web
List Template
Contains a list definition or template, which defines a list that can be provisioned in a SharePoint site.
Site,
 Web
Module
Contains a set of files with which to provision sites.
Site,
 Web
Receiver
Contains an item event receiver registration.
Web
Workflow
Contains the definition for a workflow in a list.
Site


Note: A feature should be reusable component which can be activated anywhere once deployed. We cannot control the visibility of web/site scoped features to single web application. They will be either visible in all of them or none. And a solution can be deployed to particular web application. However, a feature is always deployed globally and then can be selectively activated on multiple web/site/web app/farm depending on scope.


Alternatively In  SharePoint 2010, we have a choice to deploy a solution strictly to single site collection which does not affect other site collections in the same web application or in other site collections in other web applications. These are called "Sandboxed Solutions".

Moving sub site from one farm to another


There are mainly  two ways  to move the sub site from one farm to another in SharePoint 2010.

They are :

1> Using Windows Powershell (Expor/Import t –spweb)
2>     Using Central Admin UI

1> Using Windows PowerShell to export a site, list, or document library in SharePoint

Export-SPWeb -Identity -Path [-ItemUrl ] [-IncludeUserSecurity] [-IncludeVersions] [-NoFileCompression] [-GradualDelete] [-Verbose]

Example: To export  and Import SubSite:

Export-SPWeb -Identity http:\\ServerName:port\Site -Path c:\\backup\Exportback.cmp
Import-SPWeb -Identity http:\\ServerName:port\Site -Path c:\\backup\Exportback.cmp

2> Using Central Administration to export a site, list, or document library in SharePoint

To export a site, list, or document library by using Central Administration

1.Verify that the user account that is performing this procedure is a member of the Farm Administrators group.

2.In Central Administration, on the Home page, click Backup and Restore.

3.On the Backup and Restore page, in the Granular Backup section, click Export a site or list.

4.On the Site or List Export page, in the Site Collection section, select the site collection from the Site Collection list, and then select the site from the Site list.

5.If you are exporting a site, skip this step, Select the list or document library from the List list.

6.In the File Location section, in the Filename box, type the UNC path of the shared folder and the file to which you want to export the list or document library. The file name must use the .cmp extension.

7.If the file already exists and you want to use this file, select the Overwrite existing files check box. Otherwise, specify a different file name.

8.If you want to export all the security and permissions settings with the list or library, in the Export Full Security section, select the Export full security check box.

9.If you want to specify which version of the list or library to export, select one of the following versions from the Export versions list:

All Versions
Last Major
Current Version
Last Major and Last Minor

10.When you have specified the settings that you want, click Start Export.

11.You can view the status of all backup jobs at the top of the Granular Backup Job Status page. You can view the status of the current backup job in the Content Export section of the page. The status page updates every 30 seconds automatically. You can manually update the status details by clicking Refresh. Backup and recovery are Timer service jobs. Therefore, it may take several seconds for the backup to start.

If you receive any errors, you can review them in the Failure Message column of the Backup and Restore Job Status page. You can also find more details in the .export.log file at the UNC path that you specified in step 6.

For SharePoint 2007 Application, we will use STSADM Export and Import Commands:

Export subsite
stsadm -o export -url http://toplevel/sub_site/subsite -filename c:\subsite.bak -includeusersecurity -versions 4

Import subsite
stsadm -o import -url http://toplevel/subsite/ -filename c:\subsite.bak

We will use Powershell Export  and Import commands to move the Subsite from one Farm to other Farm in SharePoint 2010.