Transforming the SensitivityLabels column to a comma separated string value using PowerShell can be tricky.
Here is one method to achieve it.
(SensitivityLabels | Out-String).Trim().Replace("`n",",").Replace(" ","")
A full example is:
Get-AzSqlDatabaseSensitivityRecommendation -ResourceGroupName $resource_group_name -ServerName $server_name -DatabaseName $database_name |
Select-Object @{Name='DatabaseName';Expression={if($_.DatabaseName -eq $null){''}else{$_.DatabaseName}}},
@{Name='ResourceGroupName';Expression={if($_.ResourceGroupName -eq $null){''}else{$_.ResourceGroupName}}},
@{Name='SensitivityLabels';Expression={if($_.SensitivityLabels -eq $null){''}else{($_.SensitivityLabels | Out-String).Trim().Replace("`n",",").Replace(" ","")}}},
@{Name='ServerName';Expression={if($_.ServerName -eq $null){''}else{$_.ServerName}}} |
ConvertTo-Csv -NoTypeInformation -Delimiter "|"
The output looks like:
"DatabaseName"|"ResourceGroupName"|"SensitivityLabels"|"ServerName"
"testdb"|"myrg01"|"SchemaName : jobs_internal,TableName: targets,ColumnName : elastic_pool_name,SensitivityLabel : Confidential - GDPR,InformationType: Name,Rank : Medium"|"myserver"