我正在尝试使用PowerShell将SharePoint文档库的数据提取到CSV文件。我在CSv文件上获取数据正确。但是一列即“描述”上有更多的文本数据。因此,当运行脚本时,数据将进入另一行(它不会出现在一行中)。供参考,下面写了脚本,下面是我的文件。
Powershell脚本
$web = get-spweb "Site Url"
$caseLib = $web.lists | where {$_.title -eq "Document Library"}
$query=new-object Microsoft.SharePoint.SPQuery
$query.ViewFields = ""
$query.RowLimit=500000
do {
$caseLibItems=$caseLib.GetItems($query)
$query.ListItemCollectionPosition = $caseLibItems.ListItemCollectionPosition
$listItemsTotal = $caseLibItems.Count
$x = 0
for($x=0;$x -lt $listItemsTotal; $x++) {
$Description = $caseLibItems[$x]["DocumentSetDescription"]
$str = ""
if('$Description' -ne $null) {
$str = $caseLibItems[$x]["LinkFilename"].ToString() + '}' + $Description
} else {
$str = $caseLibItems[$x]["LinkFilename"].ToString()
}
Write-Output $str | Out-File "Path"
import-csv Data.csv -delimiter "}" -Header "Number", "Description" | export-csv -NoTypeInformation -Path "C:\csvfile1.csv"
}
} while ($query.ListItemCollectionPosition -ne $null)
Write-Host "Exiting"
输出文件供参考
Name Description
ABCD-123 This file imported data of system.
XYZA-231 Data migrated to next session
file need to upload on another server.
System update required.
CDFC-231 New file need to create on system
XYZA-984 system creating problem.
Source code error. update new file
HGFC-453 Maintenance updated file.
输出我想要如下
Name Description
ABCD-123 This file imported data of system.
XYZA-231 Data migrated to next session.file need to upload on another server. System update required.
CDFC-231 New file need to create on system
XYZA-984 system creating problem. Source code error. update new file.
HGFC-453 Maintenance updated file.
希望你们了解我的要求。我想说明列数据只需要我一行。