I tried to export a SharePoint Online list to .csv by using this script: How to save a list in a csv file via Powershell
Below is the script:
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SharePoint.Client') | Out-Null
$login = 'test@test.onmicrosoft.com'
$password = ConvertTo-SecureString 'password' -AsPlainText -Force
$webUrl = 'https://test.sharepoint.com/sites/test/'
$listName = 'My List'
$context = New-Object Microsoft.SharePoint.Client.ClientContext $webUrl
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials $login, $password
$web = $context.Web
$list = $web.Lists.GetByTitle($listName)
$query = New-Object Microsoft.SharePoint.Client.CamlQuery
$items = $list.GetItems($query)
$context.Load($items)
$context.ExecuteQuery()
$items | Select @{ L = "Title"; E = { $_["Title"] } }, @{ L = "Created"; E = { $_["Created"] } } | Export-Csv -Path export.csv
but I always get this Error:
Cannot contact site at the specified URL
https://sharepoint.sharepoint.com/Lists/demolist/
. There is no Web named "/Lists/demolist/_vti_bin/sites.asmx
".
When I try to load the site "manually"
I can load it.
Microsoft.SharePoint.Client
? If so, then add path in your script – Atish Dipongkor - MVP Nov 30 '15 at 11:32