How it is possible to download xml file out of this feed (website) using PowerShell?

I can authenticate with sharepoint using CSOM but do not what to do next. As service user is not administrator I cannot use "SPOService".

This script works OK for standard website, but not for Sharepoint.

$doc = New-Object System.Xml.XmlDocument

I am getting this error when using for company Sharepoint:

"The remote server returned an error: (403) Forbidden."

Thanks for your time considering this question.

1 Answer 1


The error:

The remote server returned an error: (403) Forbidden.

occurs since authentication is required for this operation in SharePoint Online. You could utilize SharePointOnlineCredentials class from CSOM API for that purpose.

The following example demonstrates how to download RSS feed from SharePoint Online and save it into file.

Complete example

Prerequisites: SharePoint Online Client Components SDK


Function Get-SPOCredentials([string]$UserName,[string]$Password)
    $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
    return New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)

Function Download-Content([string]$Url,[System.Net.ICredentials]$Credentials)
    $client = New-Object System.Net.WebClient
    $client.Credentials = $Credentials
    $client.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
    $content = $client.DownloadString($url)
    return $content

$UserName = "[email protected]"
$Password = Read-Host -Prompt "Enter the password"    
$WebUrl = "https://contoso.sharepoint.com"
$ListId = "{65CDF954-5169-47B6-9014-0151D2083821}"
#Retrieve List RSS
$listRssUrl = "$WebUrl/_layouts/15/listfeed.aspx?List=$ListId"
$credentials = Get-SPOCredentials -UserName $UserName -Password $Password
[xml]$rss = Download-Content -Url $listRssUrl  -Credentials $credentials

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.