Archive for the ‘ SharePoint ’ Category

Using Event Receivers in SharePoint Foundation 2010


I have been working with Nick Gattuccio on authoring a two-part MSDN article about using event receivers in SharePoint 2010. The first part provides a thorough explanation of what events are and how they can be developed and deployed in SharePoint. The second part provides practical examples using Visual Studio 2010.

Title: Using Event Receivers in SharePoint Foundation 2010 (Part 1 of 2)
URLhttp://msdn.microsoft.com/en-us/library/gg749858.aspx

Title: Using Event Receivers in SharePoint Foundation 2010 (Part 2 of 2)
URLhttp://msdn.microsoft.com/en-us/library/gg981880.aspx

Let me know how useful this is to you.

SharePoint 2010 site just got shared!


http://sharepoint.microsoft.com is built on top of SharePoint!

Found via SharePoint Detector.

SharePoint Detector – Chrome Extension


Ever wondered whether a site is built on top of SharePoint? Now, there is an easy way to find out. Install the “SharePoint Detector” Chrome extension located at https://chrome.google.com/extensions/detail/iglddabgpnbmcpdnmcbhhmggipakapck?hl=en, and you will get the SharePoint icon displayed in Chrome’s address bar every time you browse to a SharePoint site. You can then click on the SharePoint icon and choose to share the site by email, on your WordPress blog, LinkedIn, Twitter, Facebook and\or StumbleUpon.

For example, here is what happens when you browse to http://www.wssdemo.com.

If you decide to share on Twitter, you will get the following popup.

You can edit it as you like then post to your Twitter account. Same goes for all the other different methods of sharing..

Enjoy sharing SharePoint!

Content DB Attach using PowerShell


In this post, I’ll talk about how to attach\mount a SharePoint content database to a SharePoint web application after it has been restored\attached to the SQL server. See my previous post for details on how to restore a database using PowerShell.

SharePoint provides a cmdlet to do the content db attach. This cmdlet is called Mount-SPContentDatabase. I will create a script block wrapper for this cmdlet and show how to call it remotely. The script block below adds the SharePoint PowerShell snapin if it’s not already added, selects a web application in the farm, then calls the Mount-SPContentDatabase to do the content db attach.

[ScriptBlock] $global:AttachSPContentDB =
{
    param([string] $dbName, [string] $dbServer)

    try
    {
        # Load the Sharepoint Cmdlets
        Write-Host "Loading SharePoint PowerShell Snapin"
        $spSnapin = Get-PSSnapin | where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}
        if($spSnapin -eq $null)
        {
            Add-PSSnapin Microsoft.SharePoint.PowerShell
            Write-Host -ForegroundColor "Green" -Object "SharePoint PowerShell Snapin loaded"
        }
        else
        {
            Write-Host -ForegroundColor "Gray" -Object "SharePoint PowerShell Snapin already loaded"
        }

        # Get  web applciation url
        Write-Host "Selecting a web application in the farm"
        $webAppUrl = (Get-SPWebApplication | select -Index 0).Url

        # Mount the database at the specified SQL server to the web application
        Write-Host "Mounting database '$dbName' at SQL server '$dbServer' to web application '$webAppUrl'"
        $newDB = Mount-SPContentDatabase $dbName -DatabaseServer $dbServer -WebApplication $webAppUrl -AssignNewDatabaseId
        Write-Host -ForegroundColor "Green" -Object "Database mounted successfully with ID: " + ($newDB.Id)

        # Return content DB Id
        return $newDB.Id.ToString()
    }
    catch [Exception]
    {
        Write-Host -ForegroundColor "Red" -Object $_.Exception

        return $null
    }
}

To call this script block, pass the name of the Sql server and the name of the content database. Make sure that the content database is already restored\attached to the SQL server.

.$AttachSPContentDB "ContentDBName" "SqlServerName"

To call the script block on a remote SharePoint WFE, you can simply run

Invoke-Command -ComputerName "WFEName" -ScriptBlock { .$AttachSPContentDB "ContentDBName" "SqlServerName" }

Note that the New-SPContentDatabase cmdlet has the same effect as Mount-SPContentDatabase. The only difference is that New-SPContentDatabase creates a new SQL database if there is no database with the same name already available on the SQL server.

SharePoint Foundation 2010 on Windows 7


This MSDN article describes in detail how to install SharePoint Foundation 2010 for development purposes on Windows Vista, Windows 7 and Windows Server 2008. The purpose of this post is to focus on the SharePoint installation on Window 7 only and clear out all the details for the other operating systems.

  1. Download SharePoint Foundation 2010 x64 for free. Note that there is no x86 version of SharePoint Server, so don’t bother setting it up if you have a 32-bit machine.
  2. Create a new folder “C:\SharePointFiles” and copy “SharePointFoundation.exe” to it.
  3. Start command prompt, change directory to C:\SharePointFiles and run the following command to extract the “SharePointFoundation.exe” to C:\SharePointFiles
    SharePointFoundation.exe /extract:C:\SharePointFiles
  4. Open C:\SharePointFiles\files\Setup\config.xml, add a new <Setting> tag under the <Configuration> element, then save the file. Make sure you copy the below element as is since all of the text in the configuration file is case-sensitive.
    <Setting Id=”AllowWindowsClientInstall” Value=”True”/>
  5. Install the following Prerequisites:
  6. Enable the required windows features by running this batch file: http://cid-e38f9fc6490b29d9.skydrive.live.com/self.aspx/Public/Scripts/EnableSPWinFeatures.bat
  7. Restart your computer to complete the changes that you made to Windows Features.
  8. Install SharePoint 2010
    • Run Setup.exe under C:\SharePointFiles
    • Select standalone (Windows 7 can’t be used for production deployments of SharePoint 2010 and it’s recommended that you use Standalone only)
    • After the installation is complete, you will be prompted to start the SharePoint Products and Technologies Configuration Wizard.
      InstallSP
  9. After a SharePoint solution (.wsp file) is deployed, it recycles the application pool. To improve the initial page load times, set the optimizeCompilations property of the <compilation> tag in your web.config file (C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config) to true.
    <compilation optimizeCompilations=”true”>

SharePoint Designer 2010 is also free and can help you better design your SharePoint site(s). You can download it here.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: