'extract data from SharePoint document library to CSV using powershell

I am trying extract data of SharePoint document library to CSV file using powershell. I am getting data correct on CSv file. But one column i.e "Description" have more text data on it.So when run the script, data coming coming into another rows(its not coming in one row). For reference had written script below and my out-file in below.

Powershell Script

$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"

Output file for reference

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.

Output I want as below

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.

Hope you guys understand my requirement. I want description column data need to me in one row only.

Can anyone please help me or correct me on this script.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source