Is it possible to export a Sharepoint 2010 list while on a 2013 Sharepoint Server? I want to be able to export the contents from a list on a 2010 site into a csv file, then import it into a list on a 2013 site using PowerShell.
When running the script, I receive a :
Get-SPWeb : Cannot find an SPSite object that contains the following Id or Url:" error.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Get the Web
$web = Get-SPWeb -identity "http://www.test2010.com/site/"
#Get the Target List
$list = $web.Lists["My List"]
#Array to Hold Result - PSObjects
$ListItemCollection = @()
#Get All List items where Status is "In Progress"
$list.Items | Where-Object { $_["ID"] -ge 1} | foreach {
$ExportItem = New-Object PSObject
$ExportItem | Add-Member -MemberType NoteProperty -name "Title" -value $_["Title"]
$ExportItem | Add-Member -MemberType NoteProperty -name "ID" -value $_["ID"]
#Add the object with property to an Array
$ListItemCollection += $ExportItem
}
#Export the result Array to CSV file
$ListItemCollection | Export-CSV "c:\ListInfo.csv" -NoTypeInformation
#Dispose the web Object
$web.Dispose()
The server object model that Powershell uses to interact with SharePoint with the Microsoft.SharePoint.Powershell
snapin can only interact with a SharePoint environment running on the same server. That is, any such Powershell script that needs to interact with a SharePoint farm needs to be executed from a web front end server of that farm.
If you're running the Powershell from a server that is not part of that SharePoint farm and still need to access lists in that farm, consider using SharePoint's client object model instead. Since the client object model is accessible via .NET code, Powershell can still be used.