答案 0 :(得分:0)
我们可以使用下面的PowerShell来实现它。
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Get the Web
$web = Get-SPWeb -identity "http://sp2013/sites/team"
#Get the Target List
$list = $web.Lists["TestExportToCSV"]
#Array to Hold Result - PSObjects
$ListItemCollection = @()
#Get All List items
$listItems=$list.Items
foreach($item in $listItems) {
$ExportItem = New-Object PSObject
$ExportItem | Add-Member -MemberType NoteProperty -name "Title" -value $item["Title"]
$ExportItem | Add-Member -MemberType NoteProperty -Name "City" -value $item["City1"]
$ExportItem | Add-Member -MemberType NoteProperty -Name "State" -value $item["State1"]
$ExportItem1 = New-Object PSObject
$ExportItem1 | Add-Member -MemberType NoteProperty -name "Title" -value $item["Title"]
$ExportItem1 | Add-Member -MemberType NoteProperty -Name "City" -value $item["City2"]
$ExportItem1 | Add-Member -MemberType NoteProperty -Name "State" -value $item["State2"]
#Add the object with property to an Array
$ListItemCollection += $ExportItem
$ListItemCollection += $ExportItem1
}
#Export the result Array to CSV file
$ListItemCollection | Export-CSV "c:\ListData.csv" -NoTypeInformation
#Dispose the web Object
$web.Dispose()