Showing posts with label sharepoint 2010. Show all posts
Showing posts with label sharepoint 2010. Show all posts

Monday, February 2, 2015

Database migration from SQL 2008 to SQL 2012 for SharePoint 2010

Hi All,

We recently updated the database for our SharePoint 2010 application as Microsoft has stopped support for SQL 2008
Steps migratiing database are as follows :


  1. Install SharePoint SP1(Service Pack 1) on Application server and reboot. Test the application and make sure it is working fine 
  2. Install SharePoint SP1(Service Pack 1) on WFE server and reboot. Test the application and make sure it is working fine.
    Note : Service Pack installation is mandatory 
  3. Once your application is working fine, you need to stop following services on application server and WFE 
  4. *SharePoint 2010 Administration
  5. *SharePoint 2010 Timer
  6. *SharePoint 2010 Tracing
  7. *SharePoint 2010 User Code Host
  8. *SharePoint 2010 VSS Writer
  9. *SharePoint Foundation Search V4
  10. *SharePoint Server Search 14
  11. *World Wide Web Publishing Service
  12. *SharePoint Server Search 14
  13. *SharePoint Foundation Search V4
  14. *SharePoint Server Search 14
  15. *Web Analytics Service(in services.msc)
  16. * IIS
  17. Ensure no connection exists on the databases (Run command sp_who2 on SQL instance "Servername\Instance name" and confirm.Kill the connections if needed.
  18. Backup content database & custom database
    Note : Make sure there is enough space to take back up and other drives.
  19. Detach all user databases using and secure respective .mdf & .ldf files.Ensure all the user databases are detached before proceeding further.
  20. Start uninstall process of SQL 2008 R2. Select your database instance while uninstalling.
  21. Once uninstallation completed, re-boot the machine
  22. Start installing SQL 2012
  23. Ensure data drives and backup drives are configured to drives which have ample of space to cope up with database size requirements.
  24. Ensure Instance name 
  25. Make sure to add your Admin users and sa account as Administrators
  26. Attach all the database which were detached in earlier steps 
  27. Change database property to SQL 2012
    Will update any details/scripts related to this shortly
  28. Start all the stopped services and start IIS
  29. Test you application 
Tada ! Its should work :) 
You can also user performance monitor tool to make sure the data hasn't changed before and after database migration.
I am pretty much sure that this strategy can work on any version of SharePoint but I would advice you to carry this activities on Development server and upon successful execution can be carried on Production servers


Tuesday, October 28, 2014

Powershell training/basics

·         Always run Powershell as Administrator

·         Make sure Add-PSSnapin "Microsoft.SharePoint.Powershell" is added
If this reference is not added you will get not recognized as cmdlet,function…. Error






This can be resolved by adding Add-PSSnapin "Microsoft.SharePoint.Powershell"

    

·         Commenting,writing and in .ps1 files

Example : I have a Powershell.ps1

--Start of Script---

#Test.ps1 This is will add comment to Test powershell script

#Add
Add-PSSnapin "Microsoft.SharePoint.Powershell"

#This will write to output window
Write-Host This is Test powershell script

#Writing in different colours
Write-Host -f Red I am Red
Write-Host -f Yellow I am Red

#This will make sure the output does not disappear
powershell –noexit

--End of Script--


You can copy paste the script in txt file and save it as Powershell.ps1
On running this the output should look like this





Note : Many times the output window disappears and we fail to read the output, add the following command to retain the output window
powershell –noexit

·         Calling a function

The difference in .Net or other techniques of calling function is that in Powershell you first need to define the function and then you can make a call to function
Also it does not need circular bracket to call the function just the name of function(See example below)

--Start of Script---

#Test.ps1 This is will add comment to Test powershell script

#Add
Add-PSSnapin "Microsoft.SharePoint.Powershell"

function MySolution()
{
                Write-Host -f Yellow "I am in MySolution function"
                #Do something
}


#This is how you call a function
MySolution

#This will make sure the output does not disappear
powershell –noexit

--End of Script--

You can copy paste the script in txt file and save it as Powershell.ps1
On running this the output should look like this


  
·         Accepting inputs and doing something


--Start of Script---

#Test.ps1 This is will add comment to Test powershell script

param (
       
      [string]$action = "$(Read-Host ' Please specify the operation which you want to carry - [Add] [Retract] [Deploy] [Remove]')"
)

#Add
Add-PSSnapin "Microsoft.SharePoint.Powershell"

function AcceptInput()
{
if ($action -eq "Add")  {
               
Write-Host -f Yellow Do something if condition matches       

}
}


AcceptInput

#This will make sure the output does not disappear
powershell –noexit

--End of Script--

You can copy paste the script in txt file and save it as Powershell.ps1
On running this the output should look like this


   
Keep watching this space for more advanced scripts,would publish it soon


System.Security.Cryptography.CryptographicException was thrown. Additional exception information: The data is invalid.

Resolution :

Step 1:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14

On the 14 Properties dialog under the Security tab, select Edit.
Permissions for 14 dialog click Add… and enter the account you are using to install SharePoint example(yourdomain\username) and assign full control and Add-OK

Step 2:

Open regedit , Navigate to the following

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Secure\FarmAdmin

Delete     CredentialKeyDPEnt key

Try installing SharePoint once again






Wednesday, October 1, 2014

Powershell output disappears

Add powershell -noexit at the end of your code. 


Example :

your script
powershell-noexit  

Add this command at the end of the your script,this will display the output window as long as you don't close it manually :P


Reference :

Set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\M icrosoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied.

Resolution for this :

* Run: regedt32
* Goto HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell
* Right-Click > Permissions
* Select, and add your account, grant it "Full Control" privileges

It helped me out, being "alternative" admin, on my machine, which was prepped by an operations 
admin

Reference : 


Thursday, July 24, 2014

Techsignia Solutions SharePoint Interview Questions

Once again gave this interview without any preparation.Opening was for SharePoint Software Engineer.


  1. Introduction - a brief one with all details of work
  2. Lets say you have 40 sites and their content databases in SharePoint 2010 with SQL 2008 as back-end and you want to upgrade to SQL 2012 with SharePoint 2010 only but when migrating to 2012,there should be only 1 content DB and this content DB should contain all the content DB for 40 sites? 
  3. What is difference between Farm and Sandbox solutions
  4. How do you debug Farm & Sandbox solutions ?
  5. Can MVC implemented in SharePoint 2013 as MVC is implemented in .Net Framework 4.5?
  6. Methods to retrive list data ? 
  7. What is difference between CAML & LINQ,which one is easy for system to understand ?
  8. Which would you prefer CAML or LINQ and why ?
  9. CAML returns ListItemCollection and LINQ returns IEnumerable ? what does this mean ? Elaborate this ? which is better ? 
  10. How can the highest permission be given ? The interviewer was referring to RunWithElevatePrevilages 
  11. What is the use of it and when it can be used,what happens when used?
  12. If you have a piece of code which is 
          SPuser something = SPContent.CurrentUser; 
          
          What value does above value return when used with REWP and when used without REWP

  13.   I want to create a Web Service for a list how will I do it ? Answer: SharePoint already provides OOB list web service which list.asmx
  14.   Which one is lighter and faster when comes to access data from list ? CAML,COM or LINQ


That it ! It was very easy..like fucking easy..I could have cracked in if I they asked me such questions when  I was kid..jk :P
This was Round 1: Telephonic 
which I cleared I was called for Round 2: Face 2 Face Interview,if I attend will update the questions else end of post.
TaDa :)

What is Managed Path in SharePoint ?

What is Managed Path ?

By default, every WebApp comes with a wildcard managed path called "sites".
Example: So I could create http://myserver:7676/sites/team1

Why to create Managed Path ?

To have a specific URL other than /site we would have to create a Managed Path.
When we create a Managed Path, we have two options:   Explicit Inclusion
                                                                                              Wildcard Inclusion

Explicit inclusion :

When we are not planning to create further site collections under a specified managed path, then we use this option.
Explicit Inclusion Managed paths allows in creation of only one site collection at the exact given URL.

Example : http://myserver:7676/IT

Wildcard Inclusion :

When we want to create more than one site collection under a specific managed path, we use this option. Wildcard Inclusion Managed Paths allow unlimited site collection to be created under a given URL.

Example: http://myserver:7676/TataGroup
                http://myserver:7676/TataGroup/TCS
                https://myserver:7676/TataGroup/BPO
                https://myserver:7676/TataGroup/TataMotors

Adding Managed Path

1) Go to Central Admin->Manage Web Application ->Select the desired Web Application -> Select Managed Path from Ribbon

2) In add a new Path textbox enter  ->      \IT
Select Explicit Inclusion – Click on Add Path

3) In add a new Path textbox enter ->        \tatagroup
Select Wildcard Inclusion – Click on Add Path

Image shows how to add a Explicit inclusion Managed Path

   How this works :

  Wildcard inclusion: What happens when I try to create a site collection
   

After the managed path term”tatagroup” we created,I add a name corresponding to my subsite.I can keep creating as many site collections I want.

E     Explicit inclusion 



When I try to create a site collection with the managed path ”it” there is no textbox which indicates that I can have only 1 site collection and no further site collections can be created a with the managed path”it”


Reference : 


Tuesday, July 8, 2014

Could not find stored procedure 'proc_ECM_RetrieveTableNames' Error

Got this error while creating Managed Metadata Service Application

Cause : Error occurs when we create  managed metadata service with a  pre-existing database (even a blank database) in SQL.
Solution : We need to recreate the managed metadata service application with a new database name.


Tuesday, July 1, 2014

Add or Remove solution using Powershell in SharePoint 2010

From the Start menu, select All Programs > Microsoft SharePoint 2010 Products > SharePoint 2010 Management Shell

Deploy solutions using powershell

Add-SPSolution -LiteralPath C:\Users\jinivthakkar\Desktop\MySolution.wsp

Install-SPSolution -Identity HitCounter.wsp -WebApplication http://myserver03:8888 -GACDeployment –CASPolicies

Get-SPSolution MySolution.wsp



Removing solution

Retract Solution from SharePoint Farm

Uninstall-SPSolution -Identity MySolution.wsp -WebApplication http://myserver03:8888

Remove solution from SharePoint Farm

Remove-SPSolution -Identity MySolution.wsp




Friday, June 27, 2014

Adding attachment to list programmatically in SharePoint 2010 OR Adding list item to SharePoint 2010

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.SharePoint;

namespace ListFileUpload
{
    class Program
    {
        static void Main(string[] args)
        {
            FileUploadToList();
        }



        public static void FileUploadToList()
        {
            //file location which needs to be uploaded
            FileStream stream = File.OpenRead(@"C:\Users\jinivthakkar\Desktop\UploadToListAsAttachment.docx");
            string path = @" C:\Users\jinivthakkar\Desktop\UploadToListAsAttachment.docx ";

            //extract file name
            string fileName = Path.GetFileName(path);

            //extract extension
            string extension = System.IO.Path.GetExtension(path);

            //extract Title
            string docTitle = fileName.Substring(0, fileName.Length - extension.Length);


            //Read file and copy information in byte array
            byte[] fileBytes = new byte[stream.Length];
            stream.Read(fileBytes, 0, fileBytes.Length);

            //Site url where document which needs to be uploaded
            using (SPSite oSPsite1 = new SPSite("http://myserver01:8585/sites/Test"))
            {

                using (SPWeb oSPWeb = oSPsite1.OpenWeb())
                {
                    oSPWeb.AllowUnsafeUpdates = true;
                    //List where file needs to be uploaded
                    SPList myList = oSPWeb.Lists["MyList"];

                    SPListItem item = myList.Items.Add();
                    item["Title"] = docTitle;
                    item.Update();
                    SPAttachmentCollection attachments = item.Attachments;
                    int docID = item.ID;
                    attachments.Add(fileName, fileBytes);

                     //Item update,list update
                    item.Update();
                    myList.Update();
                    stream.Close();

                }
            }
        }

    }
}


This code reads a file on local machine and adds list item as attachment to list in SharePoint 2010

Thursday, May 29, 2014

SharePoint 2010 Tutorial Free - What is Central Administration

There is a lot of shit available on the internet but to tell in simple words

Upon installing SharePoint 2010,SharePoint provides a GUI for the user from which the user can control everything about SharePoint.

How can you access this GUI ?

Go to Start menu->Search Central Admin->Right Click->Run as Admin




It will open up this window in Internet Explorer.




      For more information free tutorial for beginners on SharePoint. Please refer other posts on my blog.

Reference : http://msdn.microsoft.com/en-us/library/ms253179(v=vs.100).aspx




The program or feature cannot start or run error


I go this error while running PreInstaller.exe while I was trying to Install SharePoint 2013

Resolution
Install .Net 4.5 manually and run the PreInstaller.exe
Tada ! Its Done
Trust me I have Googled enough but could not find a single post that could provide any resolution to this error

Unsupported 16-Bit application Error + SharePoint 2013 Installation


I go this error while running PreInstaller.exe while I was trying to Install SharePoint 2013

Resolution
Install .Net 4.5 manually and run the PreInstaller.exe
Tada ! Its Done
Trust me I have Googled enough but could not find a single post that could provide any resolution to this error

OK I am sure a lot of resolution come up on Google but none mention that the Task Scheduler Service must be running.
In my case the Task Scheduler service wasn't running.

Wednesday, May 28, 2014

SharePoint 2010 Tutorial Free - SharePoint 2010 Architecture



     It has 4 layers

    1) SharePoint Sever 2010(Enterprise/Standard)
    2) SharePoint Foundation 2010
    3) SQL Server 2008,IIS 7.0 and .Net 3.5 Framework
    4) Windows server  2008(64bit)

Considering that you have just started learning SharePoint,trust me even if you know this you have started very well.Cheers !

So normally when I go for interviews in companies ,I just draw 4 storey building and name each block as mentioned when asked to define the architecture of SharePoint 2010


And as you learn SharePoint,eventually you will come to know what each layer contains.
      

      For more information free tutorial for beginners on SharePoint. Please refer other posts on my       blog. 

Saturday, May 24, 2014

Creating folder and sub folder programmatically in SharePoint

public static void createFolderSubFolder()
        {
            string libraryName = "Test";
            string folderName = "Folder";
            string siteUrl = "http://myserver03:8989/abc";
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
              
                    using (SPSite osite = newSPSite("http://myserver03:8989/abc"))
                    {
                        using (SPWeb oweb = osite.OpenWeb())
                        {
                            SPFolderCollection folderCollection = oweb.Folders;
                            string newFolderUrl = siteUrl + "/" + libraryName + "/" + folderName;
 
                            SPFolder newFolder = folderCollection.Add(newFolderUrl);
 
                            Console.WriteLine("Folder created");
 
                            string secondFolderName = "subFolder";
                            string newSubFolderUrl = newFolderUrl + "/" + secondFolderName + "/";
 
                            SPFolder newSubFolder = folderCollection.Add(newSubFolderUrl);
                            Console.WriteLine("SubFolder created");
                            Console.ReadLine();
                        }
                    }
                });
 
            }
 
            catch (Exception ex)
            {
                throw ex;
            }
 
        }





Please note : Please check out my blog on how to create a library,content type,columns,subsite programmatically.