Posts Tagged 'sharepoint 2010'

SharePoint 2010 Incoming Email problem – email messages will go through, but attachments will not

This problem took awhile to figure out, so I figured it might be helpful to post it.

Setting up incoming email for SharePoint 2010 Enterprise, as instructed by TechNet: Configured SMTP service, set up the Exchange connector, and configured incoming email settings in SharePoint 2010 Central Administration. Created a test document library, configured it with an email alias, and tried sending a test email. Test email went through, so we’re looking good.

Next, sending an email message with an attachment (the library is configured to save both the email message and the attachment). The email message arrives without any issues, and the attachment shows up as well.

Next, another user is going to send a test message with an attachment to the same library. His email message goes through, but no attachment! What’s going on?

In Notepad I opened the message that I sent with an attachment (which worked) and compared it to the message that did not work.

In the attachment section, we’re finding the following:

My email attachment – Works in SharePoint

Content-Type: text/plain; name=”test file.txt”
Content-Description: test file.txt
Content-Disposition: attachment; filename=”test file.txt”; size=9;
creation-date=”Sat, 03 Nov 2012 04:19:07 GMT”;
modification-date=”Sat, 03 Nov 2012 04:19:07 GMT”
Content-Transfer-Encoding: base64

The other user’s email attachment – does NOT work with SharePoint incoming email.

Content-Disposition: attachment; filename=”winmail.dat”
Content-Transfer-Encoding: base64
Content-Type: application/ms-tnef; name=”winmail.dat”

Notice the difference in the Content-Type fields – mine is text/plain, while his is application/ms-tnef.

We both specified Plain Text message format in Outlook before sending the messages. So what’s causing the difference in attachment format?

After some research on the topic, we’ve stumbled upon this Technet forum thread:

The answer in this thread resolved our problem – changing the properties on the remote SMTP domain in Exchange to never use Rich Text format for messages allowed the attachments to work for all users.

How to export and import lists and libraries from a SharePoint 2010 site using Powershell

Let’s imagine this scenario:

You have an old SharePoint 2010 site and you need to copy its content to another SharePoint farm.  The site is heavily customized and moving it using traditional methods (backup/restore, export/import, save site as a template) are not going to work well.  Plus you only want content – no need to bring in all of that custom branding baggage.

You can copy the content using PowerShell and two scripts shown below.

Script # 1:   Export all lists and libraries from the source site.

add-pssnapin microsoft.sharepoint.powershell

# specify the site URL to export

$web = Get-SPWeb "http://sharepointURL/sites/site1/web1"

# specify output folder to store exported lists

$path = "c:\admin\export\"

foreach($list in $web.lists)


"Exporting " + $list.RootFolder.URL

export-spweb $web.URL -ItemUrl $list.RootFolder.URL -IncludeUserSecurity -IncludeVersions All -path ($path + $list + ".cmp") -nologfile


The output of this script should be a number of CMP files in the output directory.  Review these files and remove the lists that should not be imported (such as various Gallery lists).

Script # 2:  Import CMP files into the destination site.

add-pssnapin microsoft.sharepoint.powershell

# specify target SharePoint site to import into

$site = "http://sharepoint/sites/test1"

# specify folder containing exported lists

$folder = "C:\Admin\Import\"

$Files = Get-ChildItem $folder

foreach ($file in $files)

$name = $file.Name

"Importing: " + "$folder$name"

import-spweb $site -path ("$folder$name") -includeusersecurity -nologfile


How to remove webparts from a SharePoint page programmatically using Powershell

Let’s imagine this scenario:

You need to remove a webpart from a SharePoint page in your farm.   Easy, right?  Go to the page, enter the Edit mode, click on the webpart, select Delete.  No problem!   Now what if you had 1000 sites to remove the webpart from?   Doing it by hand is impractical, so we’ll need to use Powershell.

This will be a two step process:

Step 1, you need to run an inventory script which will generate a list of webparts and their GUIDs.

Step 2, you will use the webpart GUIDs from step 1 to run a removal script to remove the webparts.


Execute the script below using the SharePoint 2010 Management Shell (PowerShell console).  This script does the following:

1. Iterate through all web applications in the farm and open every every site collection in each web app

2. For each site collection, access the homepage  “default.aspx” and capture a list of webparts on the page and their GUIDs.

3. Write the results to a file called “results.txt”, located in the same directory as the Powershell script.

The page name “default.aspx” is hard-coded in the script but can be easily changed to another page name or page path.


Script source code

[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c") | out-null

$oContentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService;

[Microsoft.SharePoint.Administration.SPWebApplicationCollection]$waColl = $oContentService.WebApplications;

$log = ".\results.txt"    # output file name and path
$pagepath = "/default.aspx"    # change page name or page path here

"Site URL; WebPart Title ; Webpart ID" | out-file $log

$waColl1 = $waColl | where-object {$_.IsAdministrationWebApplication -eq $FALSE}

foreach ($wa in $waColl1)

foreach ($obj in $wa.Sites) 

write-host "Processing: " , $siteURL

$siteURL = $obj.URL

$site=new-object Microsoft.SharePoint.SPSite($siteURL)

$pageURL = $siteURL + $pagepath  
$webpartmanager=$web.GetLimitedWebPartManager($pageURL,  [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)   
foreach ($webpart in $webpartmanager.WebParts)
$siteURL + "; " + $webpart.Title + " ;  " + $webpart.ID | out-file $log -append   


write-host "Finished."



This script  will programmatically remove a webpart from a SharePoint page.  It takes as arguments the target site URL and the webpart GUID.   The script targets the main page “default.aspx” but can be changed to accept any other page name or page path.

Notes: Use the results from the INVENTORY SCRIPT to create a list of webparts and their GUIDs to remove. Then build a script which calls out the WEBPART REMOVAL SCRIPT using the site URLs and webpart GUIDs as arguments.

The syntax is the following:

Execute the following command in SharePoint 2010 Management shell (Powershell console):

[WEBPART REMOVAL script file name] [site URL] [webpart GUID]


remove.ps1     http://mysharepointsite     a1b83-8tyu-6897-oiy8


Script source code

[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c") | out-null [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.WebPartPages") [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")

$siteURL = $args[0]  # first argument: site URL

$webpartId = $args[1]   # second argument:  webpart GUID

$pagepath =  "/default.aspx"        # change page name or page path here

$pageURL = $siteURL + $pagepath

write-host "Processing site: ", $siteURL

Write-host "Processing page: " , $pageURL

write-host "Processing webpart ID: " , $webpartID

$site=new-object Microsoft.SharePoint.SPSite($siteURL)


$webpartmanager=$web.GetLimitedWebPartManager($pageURL, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)




write-host "Finished."

Installing SharePoint 2010 on Windows Server 2008 R2 – which server roles and features do I need?

If you’re installing SharePoint Server 2010, you will need to address the hardware and software prerequisites for SharePoint 2010.    This time around, Microsoft put together a nice TechNet page that tells you the basics of what you need before you install SP 2010:

This is a fairly comprehensive page, but there are some gaps in this document.  For instance, it tells you that you need to configure your server with the following roles:

  • Web Server (IIS) role
  • Application Server role
  • However, each of these roles consists of a number of role services – how do you know which role services need to be turned on for SharePoint 2010?   And if you miss one of the role services, you’ll get the following error when trying to install SharePoint 2010:

    “Setup is unable to proceed due to the following error(s):

    Windows Server Features or role services required by this product are not enabled. ”

    Below I’ve posted screenshots from one of my virtual machines where I was able to successfully install SharePoint Server 2010.  If you’re getting the error shown above, compare these screenshots to your configuration to find out which role services you’re missing.

    1. Turn on Application Server Role and make sure these role services are also turned on:

    2. Turn on Web Server Role and make sure that these role services are also turned on:

    3. On my VM, I also have the File Services role turned on:

    4. Go to Server Manager > Features and make sure that you have the following Features turned on:

    Good luck with your SP 2010 install!

    RSS Information Week Headlines

    • An error has occurred; the feed is probably down. Try again later.

    RSS SharePoint Team Blog

    • An error has occurred; the feed is probably down. Try again later.

    RSS InfoPath Team Blog

    • An error has occurred; the feed is probably down. Try again later.

    RSS Joel Oleson Blog

    • An error has occurred; the feed is probably down. Try again later.

    RSS Bud Ratliff blog

    • An error has occurred; the feed is probably down. Try again later.

    RSS Susan Hanley’s KM Blog

    • An error has occurred; the feed is probably down. Try again later.

    Blog Stats

    • 383,447 hits