Adobe iFilter for SharePoint 2010

Adobe PDF iFilter lets you index Adobe PDF documents in Microsoft SharePoint Server 2010 and Microsoft SharePoint Foundation 2010.

To install and configure Adobe PDF iFilter 9 in SharePoint Server 2010 and SharePoint Foundation 2010, follow these steps:

  1. Install Windows Server and SharePoint. This step includes the following tasks:
    • Install Windows Server 2008.
    • Install the SharePoint prerequisites. To do this, run the Microsoft SharePoint Products Preparation tool.
    • Install SharePoint 2010 and run the SharePoint Products Configuration Wizard.
    • Configure a server farm topology. For example, configure a Single Server Farm.
    • Create and configure a new Search Service application.
  2. Download and install Adobe PDF iFilter 9. For more information about how to download PDF iFilter 9, see Adobe PDF iFilter 9 on the Adobe Downloads website.

  3. Download the Adobe PDF file icon. For more information, see Use of Adobe icons and web logos on the Adobe website.

    Note Save the Adobe PDF file icon to the following file location:

    \Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES\
  4. Add the mapping entry to the docIcon.xml file. To do this, follow these steps:
    1. Open the docIcon.xml file in Notepad.

      Note The docIcon.xml file is located in the \Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML folder.
    2. Type the following entry in the docIcon.xml file:

      <Mapping Key="pdf" Value="pdf16.gif" />
    3. Click Save.
    4. Exit Notepad.
  5. Add the .pdf file type to the SharePoint content index.
  6. Click Start, type regedit in the Search programs and files box, and then press Enter.
  7. Locate the following registry key:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Setup\ContentIndexCommon\Filters\Extension
  8. Right-click Extension, click New, and then click Key.
  9. Type .pdf, and then press Enter.
  10. Click .pdf, right-click (Default), and then click Modify.
  11. Type the following GUID in the Value data box:

    {E8978DA6-047F-4E3D-9C78-CDBE46041603}
  12. Exit Registry Editor.
  13. Restart the SharePoint Search Service.
  14. Restart all the SharePoint servers in the server farm.

PowerShell 2.0 Adding Columns to Document Libries in a Site Collection.

Adding Columns to a SharePoint List across an entire Site Collection should be done like this using PowerShell (with Power GUI):
 
Note that the use of the following works with all the defaults... 
$fieldDateTime = [Microsoft.SharePoint.SPFieldType]::DateTime
$list.Fields.Add("Compliance Date",$fieldDateTime,$false) 

However, you get MORE Control over Field Attributes using this method:
$fldXml = "<Field Type='DateTime' DisplayName='Report Sign Off Date' Format='DateOnly' Name='Report Sign Off Date'/>"     
$list.Fields.AddFieldAsXml($fldXml) 
 
Both methods are used in the code block below. 
if ((Get-PSSnapin | ? { $_.Name -eq "Microsoft.SharePoint.PowerShell" }) -eq $null) {
    Add-PSSnapin Microsoft.SharePoint.PowerShell
}
[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges( 
{
 $site =  Get-SPSite -Identity "https://mysite.com/sites/thissite"
 Write-Host "Script Started"
 [array]$ListNames = "ListA", "ListB"
 $NumberofReportsinRecordFound = $false
 $ReportSignOffDateFound = $false
 $ComplianceDateFound = $false
 foreach($web in $site.AllWebs)
 {
  #Get number if Lists rather than using foreach as we will be modifying the List
  
  for($i=0; $i -lt $web.Lists.Count; $i++)
  {
   $list = $web.Lists[$i]
   if($list.BaseType -eq "DocumentLibrary" -and $list.BaseTemplate -notmatch "Catalog")
   {
    Write-Host $web.Title
    Write-Host $list
        
    $NumberofReportsinRecordFound = $false
    $ReportSignOffDateFound = $false
    $ComplianceDateFound = $false
      
    if($ListNames -contains $list.Title)
    {
     for($j=0; $j -lt $list.Fields.Count; $j++)
     {
      $field = $list.Fields[$j]
      if($field.Title -like "*do not use*")
      {
          Write-Host "do not use deleted!"
       $list.Fields.Delete($field)
       $list.Update() 
      }
      
      if($field.Title -like "Number of Reports in Record")
      {
       $NumberofReportsinRecordFound = $true
      }
      if($field.Title -like "Report Sign Off Date")
      {
       $ReportSignOffDateFound = $true
      }
      
      if($field.Title -like "Compliance Date")
      {
       $ComplianceDateFound = $true
      }
     }
        $fieldNumber = [Microsoft.SharePoint.SPFieldType]::Number

     if(!$NumberofReportsinRecordFound){
      $list.Fields.Add("Number of Reports in Record",$fieldNumber,$false)
      $fld = $list.Fields["Number of Reports in Record"]
     }
     
     if(!$ReportSignOffDateFound){
      $fldXml = "<Field Type='DateTime' DisplayName='Report Sign Off Date' Format='DateOnly' Name='Report Sign Off Date'/>"
      $list.Fields.AddFieldAsXml($fldXml)
     }
     
     if(!$ComplianceDateFound){
      $fldXml = "<Field Type='DateTime' DisplayName='Compliance Date' Format='DateOnly' Name='Compliance Date'/>"
      $list.Fields.AddFieldAsXml($fldXml)
     }
     $list.Description = "Inspection Reports"
     $list.Update()
    }
   }
  }
 }
 $web.Dispose()
 $site.Dispose()
 Write-Output "Script Ended"
}
)

Databases running in compatibility range, upgrade recommended.

When you apply a hot fix to SharePoint 2010 you need to run a command to complete the patch otherwise you will see this message in Central Admin "Databases running in compatibility range, upgrade recommended" under Upgrade and Migration -> Review database status, under the Status column.

To resolve this issue you need do the following.
1. Open an Administrative command prompt. CMD - Run as Administrator, or open the SharePoint PowerShell Command Window.
2. If running just the normal PowerShell Command Windows, change directory to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN
3. Run PSConfig.exe -cmd upgrade

More information can be found here: http://technet.microsoft.com/en-us/library/cc263093.aspx

Hotfixes/Cummulative Updates: http://technet.microsoft.com/en-us/sharepoint/ff800847.aspx#LatestUpdates

SharePoint Error: "Additions to this Web site have been blocked."

I came across this error today! I'm not sure how this was set but someone must have set the "Site Collection Quotas and Locks" property to Read-only.

Central Admin -> Application Management -> Site Collections -> Configure quotas and locks.

and change this section to "Not locked". 

Hope this help someone!

HTTP to HTTPS Redirect on IIS7

Redirecting all HTTP traffic to HTTPS for a single site on IIS7 is as simple as the following steps.

1. Install Microsoft URL Rewrite Module if not already installed

2. Install your SSL certificate as Normal.
(Note that you need to keep a hostname-less port 80 entry in the Bindings, as well as port 443 for SSL, in order for the redirect to work.)

3. Add the following XML to your Web.Config file. 

  <system.webServer>
    <rewrite>
    <rules>
      <rule name="HTTP to HTTPS redirect" stopProcessing="true">
        <match url="(.*)" />
        <conditions>
          <add input="{HTTPS}" pattern="off" ignoreCase="true" />
        </conditions>
        <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
      </rule>
    </rules>
    </rewrite>
 </system.webServer>

4. Do a IISRESET

5. Test the URL to ensure http redirects to https. Also test not entering a http at all, just the website host name.

6. Done.

MVC3 deploy - Could not load file or assembly 'System.Web.WebPages.Razor

Whilst deploying my newly upgraded ASP.NET MVC 3 web application to the production environment I started receiving a FileNotFoundException with the error message "Could not load file or assembly 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified." I have encountered this before so I know it is about bin-deploying that assembly. But where is the System.Web.WebPages.Razor assembly?

Since you have installed ASP.NET MVC 3 on your development machine you have all these MVC 3 assemblies installed in your GAC. Your production machine does not!

So you need to find this file and make it bin deployable however this cheeky assembly isn't in you solution so how can you do that? Well... add it. Go to Add Reference on your root web project (e.g. Web.csproj) and find System.Web.WebPages.Razor and add.

 

Now right click this assembly in your references directory and click properties.

Now you can make it bin deployable by setting Copy Local to true like so:

Note this is how to deploy the System.Web.WebPages.Razor assembly withe your ASP.NET MVC 3 web application. To deploy a typical setup of an ASP.NET MVC 3 app you will need to do the same for all of the following assemblies:

  • System.Web.Mvc
  • System.Web.Helpers
  • System.Web.Razor
  • System.Web.WebPages
  • System.Web.WebPages.Deployment
  • System.Web.WebPages.Razor as detailed above
  • Microsoft.Web.Infrastructure this will also need a reference added as above
  • WebMatrix.Data this also needs the reference


Of course you only need to add the reference to these assemblies if they are not already there - in most cases it will be. This was mainly a blog post for the slightly more complicated System.Web.WebPages.Razor.dll

Update

There is an easier way to do this if you are using Visual Studio 2010 Service Pack 1 and using Web Deploy as your publish action when publishing. You can add deployable dependencies to your ASP.NET MVC project that will choose the necessary assemblies for you. Even easier!

SharePoint 2010 Favicon

How to set Favicon to the SharePoint 2010 site?

SharePoint 2010 comes with a orange Favicon and it's present in SharePoint Root Folder\Template\Images [eg. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES\]. Open this folder and search for favicon.ico and rename the file to FaviconBackup.ico. Now copy your favicon to this folder and make sure it's named as "favicon.ico". Now restart IIS(open Command Prompt -> IISReset), clear browser cache/temproary internet files. Close the browser and reopen then browse the SharePoint site.

If mulitple sites are hosted in same farm and need to set different favicons for different sites then we have to update Master Page Code. Open the site with SharePoint Designer 2010 and select Master pages -> v4.master. The default.master is still present in SharePoint 2010 for backward compatibility and visual upgrade. But SharePoint 2010 uses v4.master only. Now click "Edit File" link to add the favicon code. If it asks for check out, click yes and continue.

Find and change the path of favicon. Save and close (If you have checked out then you need to check in and site collection administrator has to approve it via Site Settings -> Galleries -> Master pages and page layouts -> Check in and Approve). Now reset IIS/clear browser cache and check.

SQL Order By CASE with Multiple Columns

When attempting to Sort by different "MULTIPLE" Columns using a SQL Server Stored Procedure, this is the how it is done! 

USE AdventureWorks; 
SELECT   ContactID, 
         FirstName, 
         LastName, 
         Title = COALESCE(Title,'')
FROM     Person.Contact
WHERE    LEFT(FirstName,1) = 'M'
ORDER BY CASE 
           WHEN LEFT(LastName,1) = 'A' THEN RANK() OVER(ORDER BY FirstName + LastName) 
           WHEN LEFT(LastName,1) = 'M' THEN RANK() OVER(ORDER BY LastName + ', ' + FirstName, Title) 
           WHEN LEFT(LastName,1) = 'U' THEN RANK() OVER(ORDER BY LastName + ', ' + FirstName DESC) 
           ELSE                             RANK() OVER(ORDER BY LastName DESC, FirstName DESC) 
         END 

Another example: This is passing in the Sort order via a Stored Procedure Parameter. In this case @SortOrder is a varchar(100).

SELECT ItemId, ProdSize, TagNoProductIdLocation, PONo
FROM vewInvTrxSummary
ORDER BY 
        CASE WHEN @SortOrder LIKE '%Product, Tag, Location, Size, PO%' 
THEN RANK() OVER(ORDER BY Prod, TagNo, Location, Size, PONo)
                  WHEN @SortOrder LIKE '%Product, Size, Tag, Location, PO%' 
THEN RANK() OVER(ORDER BY Prod, Size, TagNo, Location, PONo)
                  WHEN @SortOrder LIKE '%Size, Product, Tag, Location, PO%' 
THEN RANK() OVER(ORDER BY Size, Prod, TagNo, Location, PONo)
                  WHEN @SortOrder LIKE '%Product, PO, Tag%'                      
THEN RANK() OVER(ORDER BY Prod, PONo, TagNo)
                    ELSE RANK() OVER(ORDER BY Prod, TagNo, Location, Size, PONo
         END