Out-GridView is showing a blank column where there is actual data
As I mentioned in the comments, there is a bug in Out-GridView
that displays blank values when there is a space or special character at the beginning or ending of a property. I don't know of a fix for whitespace bug, but you could fix the file before converting from csv like this:
(Get-Content "C:\X\Capsule\CapsulePoste.csv") -replace 'Terminaison ','Terminaison' |
ConvertFrom-CSV -Delimiter ";" |
Out-GridView
Note: As Matt and Mark stated, Mark's answer is more generalized. This quick fix makes the assumption that Terminaison
is header to fix and is found no where else in the document.
Here's a generic way to fix it after you've imported the CSV:
$CSV = import-csv "C:\x\Capsule\CapsulePoste.csv" -Delimiter ";"
$FixedObject = $CSV | ForEach-Object {
$NewObject = New-Object -TypeName PSCustomObject
$_.PSObject.Properties | ForEach-Object { $NewObject | Add-Member -Name $_.Name.Trim() -Value $_.Value -MemberType $_.MemberType }
$NewObject
}
$FixedObject | Out-GridView
This iterates through the properties of each of the resultant object and then creates a new object with those same properties but with the .Trim() method run on the name of each to remove any surrounding whitespace.
This is obviously less efficient than just fixing the CSV file before you import, but doing that (generically) could also be tricky if you can't be certain where in the CSV the headerline appears (as it's not always the first).
Of course if you just want to fix this one specific scenario, the other answer is simplest.