LinkedIn

Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts

Thursday, April 17, 2014

SharePoint PowerShell Commands

 Site Collection Backup
Backup-SPSite -Identity -Path [-Force] [-NoSiteLock] [-UseSqlSnapshot] [-Verbose] 

Site Collection Restore
Restore-SPSite -Identity -Path< Backup file> [-DatabaseServer ] [-DatabaseName ] [-HostHeader ] [-Force] [-GradualDelete] [-Verbose]

Export Site
Export-SPWeb -Identity -Path [-ItemUrl ] [-IncludeUserSecurity] [-IncludeVersions] [-NoFileCompression] [-GradualDelete] [-Verbose]
Import Site 
Import-SPWeb -Identity -Path [-Force] [-   NoFileCompression] [-Verbose]
Get all site details

$a = Get-SPWebApplication "<  $a | Select RootWeb, Url, Owner > c:\emea.csv
 $a | Select RootWeb, Url, Owner | Format-Table -AutoSize >data.csv

Deploy BDC from PowerShell
$metaStore = Get-SPBusinessDataCatalogMetadataObject -BdcObjectType "Catalog" -ServiceContext < Import-SPBusinessDataCatalogModel -Path "D:\Droppoint\test.bdcm" -Identity $metaStore -Force

Get Database names of sites
Get-SPContentDatabase | %{Write-Output "- $($_.Name)”; foreach($site in $_.sites){write-Output $site.url}} > C:\sitecollections.txt

Site Collection Sizes
Get-SPSite -Limit ALL | select url, ContentDatabase, Owner, @{label="Size in MB";Expression={$_.usage.storage/1MB}} | Sort-Object -Descending -Property "Size in MB" | Format-Table –AutoSize | Out-String -Width 100000 > D:\CollectionSize.txt
 
Get all Sub Site names
$site = Get-SPSite "http://yoursite"
 foreach ($web in $site.AllWebs) { 
  $web | Select-Object -Property Title,Url,WebTemplate   
}  
$site.Dispose()

 Search for Correlation ID in ULS logs
 
$term= ''
Select-String -pattern "$term" -Path E:\SPLogs\ULS\*.* -list

Mount and Unmount the DB

Dismount-SPContentDatabase ""
Mount-SPContentDatabase "" -DatabaseServer "" -WebApplication http://mysitename
 
Site Collections and its DB names
 Get-SPContentDatabase | %{Write-Output "- $($_.Name)”; foreach($site in $_.sites){write-Output $site.url}}
 Get Servers in Farm
 Get-SPServer
  
Get All Application Servers in Farm
 get-spserver | ? { $_.Role -eq "Application" }
 
Content Database Size
 Get-SPDatabase | select name, disksizerequired| Sort-Object disksizerequired -desc| Format-Table –AutoSize > c:\contDBSize.csv
 Storage Details of Site Collection

Get-SPSite -Limit 5| Select URL, @{Name=”Storage”; Expression={“{0:N2} MB” -f ($_.Usage.Storage/1000000)}}, @{Name=”Quota”; Expression={“{0:N2} MP” -f ($_.Quota.StorageMaximumLevel/1000000)} } | Format-Table –AutoSize | Out-string -width 10000 > C:\output.csv
 
To avoid truncation of PowerShell output: $FormatEnumerationLimit =-1
Site Owners
 
Get-SPWebApplication | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL, ID, ParentWebID,@{Name=’SiteAdministrators’;Expression={[string]::join(";", ($_.SiteAdministrators))}} | Export-CSV C:\InfoArch.csv -NoTypeInformation

Orphaned Database

$orphanedDB = Get-SPDatabase | where{$_.Name -eq "MyContentDatabase"}

$orphanedDB.Delete()


Reference:
http://praveeniyer7.blogspot.in/p/sharepoint-powershell-commands.html

Thursday, January 30, 2014

SharePoint : Latency and Bandwidth for SharePoint

Bandwidth is the amount of data that you can send through the wire.
Latency is the time taken by the data ( or packet) to travel from source to destination.

For example : If you are located in Australia and are opening a SharePoint site which is hosted in Seattle ( USA) and if it takes 1/10th of a second to open that page, then the network latency between your machine and the machine hosting the site is 1/10th of a second.

For SharePoint deployment we have some guidelines to consider with respect to bandwidth and latency. Below table summaries with different scenarios



With respect to backup/restore of database in SharePoint 2010, network drives with 1 millisecond or less latency between them and the database server will perform well.

http://blogs.msdn.com/b/sharepoint__cloud/archive/2012/09/20/guidance-on-latency-and-bandwidth-for-sharepoint-2010.aspx

Tuesday, December 10, 2013

SharePoint : Representational State Transfer (REST)

The SharePoint 2010 Representational State Transfer (REST) interface is a WCF Data Service that allows you to use construct HTTP requests to query SharePoint list data. Representational State Transfer, aka REST, is an architectural style for web-based data access, an alternative to other techniques like SOAP Web Services and Remote Procedure Calls. OData is a protocol – a standardized way to implement REST to surface, query, and manipulate data. OData is an open web-data protocol developed by Microsoft. OData is all about web-based data access; OData can make almost any kind of structured data collection available to any kind of platform, because all data access is via plain old HTTP, and the data is served up as XML (or JSON) in an Atom-style RSS feed.
ODataQuery by URL, Answer by RSS
OData is built on the Entity Data Model. A RDBMS like SQL Server, tables contain rows; in OData, Collections contain Entries. In a database, tables can be related; in OData, Collections can be associated. A row has columns. An Entry has properties. Tables may have keys; Collections always have keys. Browsing to the service root of an OData service usually displays an Atom+XML list of all available Collections.
Entity Data Model (EDM) and OData have parallel terms:
EDM (What to query)
OData (What is returned)
Entity Set
Collection
Entity Type
Entry
Property of an Entity Type
Property of an Entry
Navigation Property
Link
Function Import
Service Operation
An OData Url has three parts: a Service root, a resource path, and (optionally) query string options. We”ve seen the service root, which typically returns a list of all available Collections. The resource path is kind of like a relative URL, and identifies a Collection or a single Entry or a property of an Entry. Basically the resource path drills down through the entity model to get to a particular object. OData URLs are usually case-sensitive, so take care with spelling. For example, http://services.odata.org/Northwind/Northwind.svc/Customers(”ALFKI”) returns just the ALFKI Customer, which is a single Entry identified by its key

Reference:

http://www.mindsharp.com/blog/2012/07/sharepoints-rest-an-odata-overview/

Writing Event Handlers for a Specific Sharepoint 2010 List

When you register Event handlers get added to all the lists of that template. for eg: Lets take a common scenario. Lets say you will have at least 2 custom lists in your site List1, List2. Now you write an event handler that you want to trigger on operations on one list List1. But this event handler also gets attached to List2 without you intending for.
Solution:
            There are may solutions you may find for this. One and most straight forward is write a feature stapler. But again writing a stapler is not easy and takes a lot of time. Also it's one more feature added to your site.
            The second solution(not too obvious) also exists. Now if you are writing a feature you got to have a Elements.xml file(At least I have to have one). Here making some tweaks will solve your problem.
I have created a solution called GG.BlogsEventHandler. I have written Asynchronous receiver. Below is how my Elements.xml looks like.



Look carefully at line #4. Do you see any difference? By default you will have


where xx=template id of your list. Custom Lists have "301" . Instead of giving a template Id, I have given site relative Url of the List.

SharePoint Timer Job – SPJobLockType

There are 3 SPJobLockType  available:

1.       SPJobLockType.None -- if you set it none, the instance will run in all the available servers in the Farm (e.g. Application Server Timer Job)
2.       SPJobLockType.ContentDatabase – this will cause 3 instances to be running in each of the Web-Frontends.
3.       SPJobLockType.Job – this will cause only one instance of the job to run on any of the front-end servers. (Note: it is possible to see multiple instances listed in the Job Status .. but if you look at the time it was last run.. only one would have run lately)

If you have to develop a job, you have to first decide on the type of lock you need for your job.

E.g. If your job does something with the files in the Web-Frontend server you might want to use a ContentDatabase lock.. or if you have something that manipulates the data in a list.. you will have to use Job lock.
Note: If you use other types of locks to manipulate the data in a list.. the multiple job instances will run simultaneously and cause Data Update conflict errors.
Note: If for any reason you re-deploy your job.. either put the dll directly in GAC or deploysolution.. make sure you restart the 'Windows Sharepoint Services Timer' service. (OWSTIMER.EXE)Note: The account used by the Timer service should have access to the Content Database.

Here are some sample code(s) of a custom timer job definition:
[Guid("{62FF3B87-654E-41B8-B997-A1EA6720B127}")]
class MyTimerJob1 : SPJobDefinition
{
    public MyTimerJob1()
        : base()
    { }

    public MyTimerJob1(string name, SPService service, SPServer server,
        SPJobLockType lockType) : base(name, service, server, lockType)
    { }

    public MyTimerJob1(string name, SPWebApplication webApplication, SPServer server,
        SPJobLockType lockType) : base(name, webApplication, server, lockType)
    { }

    public override void Execute(Guid targetInstanceId)
    {
        //Execute Timer Job Tasks
    }
}
Remember that the different server roles that we can find on a Sharepoint farm are:

  • Database Server: the server that hosts the Microsoft SQL Server database for the farm. Since Sharepoint Foundation is not typically installed in this server, no jobs will run here.
  • Web Front End Server: server where the Microsoft SharePoint Foundation Web Application service is running on.
  • Application Server: Any other Sharepoint server.
Here are a couple of examples on where the jobs will run depending on the parameters passed to the constructor:

//Job associated with a web app, no server in particular and none lock:
//  will run on all fron end servers.
var jobRunningOnAllFrontEndServers = new MyTimerJob1("mytimerjob", 
    SPWebApplication.Lookup(webAppURI), null, SPJobLockType.None);

//Job associated with a web app, one front end server and job lock:
//  will run only in the frontEndServer1 server.
var jobRunningOnAParticularFronEndServer = new MyTimerJob1("mytimerjob", 
    SPWebApplication.Lookup(webAppURI), fronEndServer1, SPJobLockType.Job);

//Job associated with a webApp, and an app server and lock type job: 
//  it won't run on any server since the server specified is NOT running 
//  the Web Application Service
var jobRunningOnNoServer = new MyTimerJob1("mytimerjob", 
    SPWebApplication.Lookup(webAppURI), appServer1, SPJobLockType.Job);

//Job associated with the timer service, a particular app server and none lock:
//  will run on the appServer1 server only.
var jobRunningOnAppServer = new MyTimerJob1("mytimerjob", 
    SPFarm.Local.TimerService, appServer1, SPJobLockType.None);

Thursday, April 28, 2011

Disaster Recovery in SharePoint Server 2010

Overview:


We define disaster recovery as the ability to recover from a situation in which a data center that hosts SharePoint Server becomes unavailable. The disaster recovery strategy that you use for SharePoint Server must be coordinated with the disaster recovery strategy for the related infrastructure, including Active Directory domains, Exchange Server, and Microsoft SQL Server.

The time and immediate effort to get another farm up and running in a different location is often referred to as a hot, warm, or cold standby. Our definitions for these terms are as follows:


Cold standby Second data center that can provide availability within hours or days. Have backups on a regular basis, and has contracts in place for emergency server rentals in another region. You can recover by setting up a new farm in a new location, (preferably by using a scripted deployment), and restoring backups. Or, you can recover by restoring a farm from a backup solution such as Microsoft System Center Data Protection Manager 2007 that protects your data at the computer level and lets you restore each server individually. Often the cheapest option to maintain, operationally.

Often an expensive option to recover, because it requires that physical servers be configured correctly after a disaster has occurred. The slowest option to recover.

Warm standby A second data center that can provide availability within minutes or hours. . A business ships virtual server images to local and regional disaster recovery farms. You can create a warm standby solution by making sure that you consistently and frequently create virtual images of the servers in your farm that you ship to a secondary location. At the secondary location, you must have an environment available in which you can easily configure and connect the images to re-create your farm environment. Often relatively inexpensive to recover, because a virtual server farm can require little configuration upon recovery. Can be very expensive and time consuming to maintain.

Hot standby A second data center that can provide availability within seconds or minutes. A business runs multiple data centers, but serves content and services through only one data center. You can set up a failover farm to provide disaster recovery in a separate data center from the primary farm. An environment that has a separate failover farm has the following characteristics:

• A separate configuration database and Central Administration content database must be maintained on the failover farm.

• All customizations must be deployed on both farms.

• Updates must be applied to both farms, individually.

• SharePoint Server content databases can be successfully asynchronously mirrored or log-shipped to the failover farm

Often relatively fast to recover. Can be quite expensive to configure and maintain.



Backup and recovery overview (SharePoint Server 2010):

The backup architecture and recovery processes that are available in Microsoft SharePoint Server 2010, including farm and granular backup and recovery, and recovery from an unattached content database. Backup and recovery operations can be performed through the user interface or through Windows PowerShell cmdlets. Built-in backup and recovery tools may not meet all the needs of your organization.

Backup and recovery scenarios

Backing up and recovering data supports many business scenarios, including the following:

• Recovering unintentionally deleted content that is not protected by the Recycle Bin or versioning.

• Moving data between installations as part of a hardware or software upgrade.

• Recovering from an unexpected failure.



Backup architecture

• SharePoint Server 2010 provides two backup systems: farm and granular.

Farm backup architecture

• The farm backup architecture in SharePoint Server 2010 starts a Microsoft SQL Server backup of content and service application databases, writes configuration content to files, and also backs up the Search index files and synchronizes them with the Search database backups.

Granular backup and export architecture

• If you are running SQL Server Enterprise, the granular backup system can optionally use SQL Server database snapshots to ensure that data remains consistent while the backup or export is in progress. When a snapshot is requested, a SQL Server database snapshot of the appropriate content database is taken, SharePoint Server uses it to create the backup or export package, and then the snapshot is deleted. Database snapshots are linked to the source database where they originated. If the source database goes offline for any reason, the snapshot will be unavailable.

References:
http://technet.microsoft.com/en-us/library/ff628971.aspx
http://technet.microsoft.com/en-us/library/ee663490.aspx

Thursday, April 14, 2011

SharePoint 2010 custom masterpage with code behind file

Master Page code behind should like this:

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MasterPageWithCodeBehind.MasterPageModule

{

public class _starter : MasterPage

{

protected System.Web.UI.HtmlControls.HtmlGenericControl divRibbonContainer;
protected Label Label1;

protected void Page_Load(object sender, EventArgs e)
{

     divRibbonContainer.Visible = false;
     Label1.Text = "Hello World!";
}

}

}
 
In the application pages you should have a attribute like this:
Add the following Inherits attribute:
Inherits :
To combine the code-behind file with the masterpage there need to be an attribute added to the masterpage directive.
The following data is needed:
■Namespace of the class & Type/Class name (these need to be seperated by a dot) (MasterPageWithCodeBehind.MasterPageModule._starter)

■Strongname/Assembly in my case was this the same as the projectname (MasterPageWithCodeBehind)

■Version (Version=1.0.0.0)

■Culture (Culture=neutral)

■PublicKeyToken (PublicKeyToken=f8a88530fbc7b81b)In the masterpage navigate to the following:

In our case the Inherits would contain:
MasterPageWithCodeBehind.MasterPageModule._starter, MasterPageWithCodeBehind, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f8a88530fbc7b81b
 
Deploy your SharePoint 2010 project and load the default site.Your ribbon should be gone and a text like Hello World! should be visible.
Refer the following link for details:
http://rburgundy.wordpress.com/2010/03/10/sharepoint-2010-custom-masterpage-with-code-behind-file-%e2%80%93-part-2/

Friday, June 11, 2010

Delete listitems from Sharepoit List

We cannot use the following code, we may get the following error:
"Collection was modified; enumeration operation may not execute."


using (SPSite site = new SPSite("http://server")) {
using (SPWeb web = siteCollection.OpenWeb()) {
SPList list = web.Lists["MyList"];

foreach (SPListItem item in list.Items) {
item.Delete();
}
}
}

We also cannot use the following code:

for (int i = 0; i < list.Items.Count; i++) {
list.Items.Delete(i);
}



The correct code is as follows:
The correct method for deleting list items is to use a decrementing For loop.

for (int i = list.Items.Count - 1; i >= 0; i--) {
list.Items.Delete(i);
}

For details refer the following link.

Programmatically Create a Sharepoint List (SPList)

The following code snippet can be used to create a list in sharepoint site. The following example I have illustrated only DocumentLibrary creation.

public static bool CreateSPList(SPWeb web, string listName, SPListTemplateType type)
{
bool create = false;
try
{
if (type == SPListTemplateType.DocumentLibrary)
{
web.Lists.Add(listName, listName, SPListTemplateType.DocumentLibrary);
return true;
}
}
catch (Exception ex)
{
return false;
}
return create;
}

Programmatically Check Folder Exists in Sharepoint

The following code can be used to check the folder exists in Sharepoint Site:

public static SPFolder CheckFolderExists(SPList targetList, string folderUrl)
{
SPFolder folder = null;
if (string.IsNullOrEmpty(folderUrl))
return targetList.RootFolder;

SPFolderCollection col = targetList.ParentWeb.Folders;
foreach (SPFolder item in col)
{
foreach (SPFolder fol1 in item.SubFolders)
{
foreach (SPFolder fol2 in fol1.SubFolders)
{
if (fol2.Name.ToLower() == folderUrl.ToLower())
{
folder = fol2;
return folder;
}
}
}

}

return folder;

}

Tuesday, December 16, 2008

Sharepoint Features



This image displays the features of the Sharepoint in pie chart format. The pies on the right half (Collaboration, Portal & Search) form the part of core framework .i.e. WSS 3.0.

Why use Sharepoint for Application Development? Part II

Application Development in Sharepoint hardly requires any coding. Why? See the following list:

• Entities - these get created as "Content Types" in WSS and require no coding.
• Metadata - these get created as "Site Columns" in WSS and get bound together as "Content Types". No coding.
• Database - WSS automatically stores all metadata in its own database without the need to create additional structures. No coding
• Connections - connections to the database handled by the WSS provisioning engine. No coding.
• Security - this is handled by WSS through NTLM, Kerberos, SSO or "Forms Based" authentication. No coding
• Authentication - this is done by IIS and WSS. No coding
• Optimising - WSS has built in caching components that can be configured using the browser.
• Scalability - the topology of WSS allows it to scale out into a farm configuration. All web pages are stored in the database as metadata and can therefore be rendered from any amount of WFE's.
• Auditing - WSS has built in audit trails.
• Web page builds - the provisioning engine of WSS creates web page on the fly without the need of coding them. The layouts can be controlled using the browser or SPD.

Why use Sharepoint for Application Development? Part I

B'coz we get so much as out of box feature in the new platform instead of using Visual Studio, C# etc for developing web based applications. Here also we may still need Visual Studio for many applications, but not to begin with. Building on this platform is cheaper, faster, less error prone and delivers more consistent user experience. So it doesn’t make sense to build a new application if platform provides all the stuff we need to develop the applications.

What we get as out of the box functionalities?
• Advanced document management
• Workflow
• Records
• Web content management
• Connection to get backend systems with BDC
• Collaborative spaces
• Search Centre
• Dash boards
• Excel services
• Forms Dev Environment

.Net Framework 3.0 in WSS 3.0

The following features of .Net Fraemwork 3.0 are used in WSS 3.0:

Windows Workflow Foundation (WF):
Windows Workflow Foundation (WWF) is a Microsoft technology for defining, executing, and managing workflow's. This is used extensively by WSS 3.0 to run built-in workflow's that ship with the product, but also provides the ability of building new and custom workflow's. This can either be done using Visual Studio or SPD (Sharepoint Designer).

Windows Communication Foundation (WCF):
The WCF programming model unifies web services, .NET Remoting, distributed transactions, and message queues into a single service-oriented programming model for distributed computing. This removes the complexity of trying to manager each of these methods individually in the application and also creates a standard to manage these communication mechanisms.

Windows Presentation Foundation (WPF):
WPF is a consistent programming model for building solutions that enables the use of richer controls, design, and development in Windows programs. This now allows the developer to easily insert and use components such as video, animation, 2/3D graphics, and various kinds of documents into the application whist removing the complexity of trying to use API's directly like we did in the past.

Windows CardSpace (WCS):
WCS (originally called Info Card) helps people keep track of their digital identities as distinct information cards. This allows easier authentications on many web sites without the need to re-enter usernames and passwords or even credit card information. It is also encrypted and therefore a lot more secure

Content Types in WSS 3.0

Content types are reusable settings for a specific type of content.These are used when we have to maintain different kinds of metadata about each kind of content. A content type is a group of reusable settings that describe the shared behaviors for a specific type of content.

Sharepoint Development

Whenever we refer "Sharepoint Development", we are not actually building a site but instead we are creating a "type" of site which are referred as "Site Definitions". We may create a new Team Site or a Document workspace or a Meeting workspace or a Blog or a Wiki site, but actually we are creating a type of site or definition of a site based on site templates. Site definitions are made up of features like document library, picture library or form library.
Sharepoint sites are not individual web applications,they have no pages of their own. They are nothing but data and only data. Everything is maintained in database (sql server) somewhere, but nothing on file system. If you look at the Sharepoint filesystem only handful of things will be present on file system, but everything else resides in database.

What is MOSS 2007?

WSS 3.0 is shipped free of cost with Windows 2003 Server. But MOSS 2007 is enhanced version of WSS 3.0 which is not available for free. MOSS 2007 stands for Microsoft Office Sharepoint Services 2007. MOSS 2007 is built over WSS 3.0, that means the base framework still remains WSS 3.0. So along with the core functionalities offered by the base framework, MOSS 2007 offers many more out of the box new functionalities. The following are the few of the new functionalities which I've listed:

Enterprise Content Management – i.e. Web Content Management.
• Business intelligence using Excel Services, Report Center & Search Center
BDC – provides the access to the external data residing within other business application enabling display and interaction with external data.
• Single Sign-On (SSO) - Allows the User to log onto a variety of applications with a single user name and password
• Business intelligence dashboards - Rich, interactive BI dashboards
• Personalization – Providing customized user browser experience.

What is WSS 3.0?

WSS 3.0 is a platform to develop collaborative applications along with this it also provides framework for document management for storing & sharing documents.

Previously Windows Sharepoint Services was only known as Document Management System (DMS). Over the years WSS has changed. Now WSS 3.0 has a dual nature. It was a storage application back in 2003. It still is a storage application, but it can now host web applications also.

WSS is at a stage where it can serve as both a solution and development platform.

Intro about me

I'm Vinay Chavadi, software professional with  more than 13 years of professional experience with extensive experience in architecture, design and implementation of software solutions, specializing in Microsoft technologies with around 5 years of experience in Sharepoint platform. Presently working as a Sharepoint Solution Architect in Global IT Company . Has experience in all phases of the software life cycle beginning with gathering requirements, architecture, design, implementation, testing, deployment and support phases. Has skills in building credibility, establish rapport, and maintain communication with stakeholders at multiple levels, including those external to the organization.

Core Competencies:

■Solution Selling
■Business Needs Assessment.
■Technology and Business Process Integration
■Collaboration Platforms (Sharepoint & Salesforce)

Specialties:MOSS 2007, Sharepoint 2010, WSS 3.0, Biztalk 2006 R2, Biztalk 2009, ASP.Net, C#, Salesforce, Force.com