In 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:
if ($list.EnableSyndication -eq $false)
$list.EnableSyndication = $true
write-host "RSS Feeds enabled on list:" $list.Title
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
#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:
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
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:
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
Next, we add the columns to the view as required.
#Add new columns using their display name
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
#Dispose of web object