Wednesday, 24 November 2010

Configuring list RSS feeds in SharePoint using PowerShell

In my previous article, I covered how to enable and configure RSS feeds at the site level with PowerShell, including disabling list RSS feeds by default so that you can choose which lists you want to enable when required.

In this article, I will go through how to enable RSS feeds on a list and configure the various options associated with them, including selecting the list columns to be published in the feed.

 

Enabling RSS Feeds on a list

The first part of the script connects to the site and list you want to configure:

#Get site collection and list objects
$web = Get-SPWeb http://portal
$list = $web.Lists["Documents"]

We then enable RSS feeds on the list, if currently disabled. This is the same thing as clicking on the following option in the browser UI:

image

if ($list.EnableSyndication -eq $false)
{
    $list.EnableSyndication = $true
    $list.Update()
    write-host "RSS Feeds enabled on list:" $list.Title
}
else
{
    write-host "RSS Feeds already enabled on list:" $list.Title
}

 

List RSS properties

For configuring the properties of the RSS feed, we need to use the EnsureRssSettings method to check the RSS settings of the list and connect to the root folder:

#Checks the RSS settings of the list, and, if necessary, updates them to ensure that the most current settings are used
$list.EnsureRssSettings()
#Get root folder which contains RSS configuration properties
$rootFolder = $list.RootFolder

The commands for setting the properties themselves depends on the options you wish to set with the script. The table below shows the code for setting each of the properties along with the section of the UI they correspond to:

RSS Channel Information image
RSS Channel settings can be set with the following code. Where there is a Yes/No option, as with the truncate multi-line text setting above, use 0 to specify No and 1 to specify Yes:

$rootFolder.Properties["vti_rss_LimitDescriptionLength"] = 0
$rootFolder.Properties["vti_rss_ChannelTitle"] = "Intranet: Documents"
$rootFolder.Properties["vti_rss_ChannelDescription"] = "RSS feed for the Documents list."
$rootFolder.Properties["vti_rss_ChannelImageUrl"] = "/_layouts/images/siteIcon.png"

Document Options (document libraries only) image
$rootFolder.Properties["vti_rss_DocumentAsLink"] = 1
$rootFolder.Properties["vti_rss_DocumentAsEnclosure"] = 1
Item Limit image
$rootFolder.Properties["vti_rss_ItemLimit"] = 25
$rootFolder.Properties["vti_rss_DayLimit"] = 7
Other Options (not configurable from the UI) These options are hidden from the UI and only configurable through code/PowerShell. I haven’t tested either of them, but assume the first specifies if you want to display the RSS icon with the feed (default Yes) and the second configures the RSS feed for display on the Quick Launch menu (default No):

$rootFolder.Properties["vti_rss_DisplayRssIcon"] = 1
$rootFolder.Properties["vti_rss_DisplayOnQuicklaunch"] = 0

Of course, as the option to configure these settings are both hidden from the UI, they may not do anything at all!

Once you have configured the properties of the list RSS feed, you have to apply them with the following update commands:

#Update root folder and list with the changes
$rootFolder.Update()
$list.Update()

 

Selecting list columns for use in RSS Feeds

The PowerShell script code in this section will include the following list columns for display in the RSS feed:

image

Columns marked with an asterisk will map to standard RSS tags – e.g., "Created by" is mapped to the RSS "Author" tag. All other columns will display in the RSS description tag.

First, we need to get a hidden view called “RssView” and delete all currently selected columns from the view:

#Get RSS View and delete all existing columns
$rssView = $list.Views["RssView"]
$rssViewFields = $rssView.ViewFields
$rssViewFields.DeleteAll()

Next, we add the columns to the view as required.

#Add new columns using their display name
$rssViewFields.Add("Title")
$rssViewFields.Add("Version")
$rssViewFields.Add("Modified By")

The method I have used above allows you to specify the display name of the columns to be added. You could choose to use internal column names instead with this code for each column: $rssViewFields.Add($list.Fields.GetFieldByInternalName("fieldname"))

Finally, we have to update the RSS view and dispose of the web object:

#Update the RSS View
$rssView.Update()

#Dispose of web object
$web.Dispose()

33 comments:

  1. Thanks a lot. I am new to SharePoint and your post solved my issues. Thanks for sharing, keep it up!

    ReplyDelete
  2. This could get me started to customize the RSS feed on an Allnet ALL4550 line ticker display where I'd like to get rid of "Body:" and "Created By:". Thanks for posting it.

    ReplyDelete
  3. Very informative post. Nice work.

    ReplyDelete
  4. This blog is so nice to me. I will continue to come here again and again. Visit my link as well. Good luck
    cara menggugurkan kandungan

    ReplyDelete
  5. dự án chung cư vinhomes nguyễn trãi là một quần thể đô thị hiện đại chung cu vinhomes nguyen trai được trang bị nội thất tinh tế thiết kế vinhomes nguyễn trãi sang trọng vinhomes nguyen trai đẳng cấp kết hợp cùng tiện nghi vinhome nguyen trai cao cấp vinhomes nguyễn trãi là điểm đến lý tưởng vincom nguyen trai đầy đủ cho người tiêu dùng vincom nguyễn trãi có bán giày nam các loại giày công sở nam đẹp nhất

    ReplyDelete
  6. Times distributing any bet, You are investing buy this one brand from owner if you're earning prospective buyer. Which you have digest and consented to the worldwide delivery overseas app conditions goes into business in a good eye-port nicely loss. Significance expense above estimated might be be governed by change in case you the better say several..

    Due to publishing one's own say, You dfb trikot müller are investing buy a goods from the vendor if you are the taking prospective buyer. You read and concure with the worldwide maillot foot 2018 delivering Coach Outlet Online Store approach small print starts advertising in a juegos de futbol totally new windowpane otherwise bill. Signific complaints years ago quotation are hands calendario de futbol down short sale change if you happen to speed up you maillot de foot personnalise the greatest number of Maglie Da Calcio a Poco Prezzo buy total variety..

    The following add up comprises of Camisetas De Futbol Baratas related methods steps, Income income tax, Stock broker or penalty dues. This one money is be governed by change before you make fund. The Maillot De Foot Pas Cher local surf forecast in an western european component maintain except england, manuel neuer trikot rot Importance value-added tax on that get certainly not recoverable.

    ReplyDelete
  7. This article is interesting and useful. And let me share an article about health which insha Allah will be very useful if we use it again for others.

    Cara Mengobati Penyakit Gula Darah
    Obat Untuk Penyakit TBC
    Cara Mengobati Jamur Mulut

    ReplyDelete
  8. This article is interesting and useful. Thank you for sharing. And let me share an article about health that God willing will be very useful. Thank you :)

    Cara Mengobati radang Usus
    Cara Mengatasi sakit pundak dan Leher kaku
    Cara Menghilangkan Benjolan di Bibir
    Obat Nyeri haid
    Tips Menghilangkan Wajah kusam
    Cara Mengobati Bisul

    ReplyDelete
  9. También puede visitar una tienda de ladrillo y mortero de Michael Kors o su sitio web y comprar directamente un bolso Michael Kors desde allí. Usar un bolso de Michael Kors les permite a los demás reconocer que el habitante urbano educado toma la moda realmente con seriedad. Los bolsos de hombro son particularmente refinados y elegantes.

    {Bolsas Michael Kors Precios | Bolsos Michael Kors Outlet | Michael Kors Rebajas}

    En vacker konstnärlig skapelse av vävt läder, som ger ett skalskaligt utseende - liknar en snakeskin eller fiskhud, linjer utsidan av påsen. Läderens bältros är små läderringar. Det finns också gyllene accenter på väskan. Slutresultatet är svagt liknar kedjepost.

    {Michael Kors Rea | Michael Kors Väska Rea | Michael Kors Plånbok}

    ReplyDelete