Page copy protected against web site content infringement by Copyscape


In MOSS 2007, there was no possible way to browse unattached content database (excluding third party tools). SharePoint 2010 lets you browse a content database without attaching it to the farm. The following walkthrough will show you the steps to browse an unattached content database.

I will show you the steps to recover a list that was deleted from one of the site collections.


Here is my original list named “TKDemoList” consisting of 2 list items with attachments.


The list is deleted



Now, to recover the list. Go to Central Admin –> Backup and Restore –> Recover data from an unattached content database (under “Granular Backup”)




In the Unattached Content Database Recovery screen, fill in the information. WSSContentDemo is the backup copy of my original content database before the list was deleted.


In the Browse Content screen, pick the site collection, site and the List



You can also browse all sites by changing the site in the Site drop down list. The following shows the sites present in my site collection



In the Site or List Export, type in the filename (in the format of \\servername\sharename\filename.cmp)



Once the export is done, you can verify the job status. You can also browse to the folder where the cmp file is created to view the export log file.





The next step is importing the list into our site collection. We will use the mighty SharePoint Power Shell to do this. You have 2 options, you can either type in the Import-SPWeb command in the following format

Import-SPWeb -Identity <Site URL> -Path <Export file name> [-Force] [-NoFileCompression] [-Verbose]

(or) just Import-SPWeb and let it walk you through the steps



You can review the log file that is created and you will see all the list items and attachments restored. The screen shot shows the 2 documents that were imported.



Back to the site collection, you can view the TKDemoList that was restored.




I did notice that Import-SPWeb took a while to import 2 list items with a collective attachment size of 1.2 MB. It will be interesting to see the performance once the RTM product is out.

Time for Phillydotnet usergroup Code camp. We have a whole track dedicated to SharePoint. My session will cover sandboxed solutions development with SharePoint 2010 and SharePoint 2010 Application Lifecycle management (ALM) using Visual Studio 2010 and TFS 2010.

As of this date, the registrations for Code camp is close to 500 participants. 12 different tracks.

Main Link:

Session Details:

Join in and see you there!


Page copy protected against web site content infringement by Copyscape

Here is the code snippet that would invoke SharePoint 2010 Powershell cmdlets from VS 2010

   1: private void invokeSPCmdlet()

   2:         {

   3:             // create runspace configuration

   4:             RunspaceConfiguration config = RunspaceConfiguration.Create();


   6:             // PSSnapIn exception object

   7:             PSSnapInException Ex = null;


   9:             try

  10:             {

  11:                 //add Microsoft SharePoint PowerShell SnapIn

  12:                 PSSnapInInfo pssnap = config.AddPSSnapIn("Microsoft.SharePoint.PowerShell", out Ex);


  14:                 //create powershell runspace

  15:                 Runspace cmdlet = RunspaceFactory.CreateRunspace(config);


  17:                 cmdlet.Open();


  19:                 RunspaceInvoke scriptInvoker = new RunspaceInvoke(cmdlet);


  21:                 // set powershell execution policy to unrestricted

  22:                 scriptInvoker.Invoke("Set-ExecutionPolicy Unrestricted");


  24:                 // create a pipeline and load it with command object

  25:                 Pipeline pipeline = cmdlet.CreatePipeline();


  27:                 Command cmd = new Command("Get-SPSite"); // Using Get-SPFarm powershell command

  28:                 pipeline.Commands.Add(cmd);



  31:                 pipeline.Commands.Add("Out-String"); // this will format the output

  32:                 IEnumerable<PSObject> output = pipeline.Invoke();


  34:                 pipeline.Stop();

  35:                 cmdlet.Close();


  37:                 // process each object in the output and append to stringbuilder

  38:                 StringBuilder results = new StringBuilder();

  39:                 foreach (PSObject obj in output)

  40:                 {

  41:                     results.AppendLine(obj.ToString());

  42:                 }

  43:                 //set the output to a multi-line text box

  44:                 textBox1.Text = results.ToString();

  45:             }

  46:             catch (Exception exError)

  47:             {

  48:                 MessageBox.Show(exError.Message.ToString());

  49:             }

  50:         }


You have to reference System.Management.Automation and include the following statements

using System.Management.Automation;
using System.Management.Automation.Runspaces;


There are various ways to invoke SP 2010 cmdlets, but the code snippet shows using RunspaceConfiguration to achieve this. On pasting the method into a standard windows form with a command button and text box, this is what the output would look like



The code snippet calls the “Get-SPSite” cmdlet from SharePoint Windows PowerShell.


  • Make sure you are targeting Framework 3.5 in VS 2010
  • Platform target is set to x64


I have used a simple text box to show results. There are many possibilities like feeding results to SilverLight (or) Visio Services…

Hope you find this useful!