When I run this command, it returns the output with lots of blank lines.
Get-Host | Select Name, Version | Format-List
I tried using ExpandProperty
but it still leaves me with one blank line at the end of the output, is there a way to remove the last blank line?
Get-Host | Select -ExpandProperty Name, Version | Format-List
If you really need the format that Format-List
provides, then you can use Out-String
and Trim() to get rid of empty lines:
Get-Host | Select Name,Version | Format-List | Out-String | ForEach-Object { $_.Trim() }
But, depending on your needs, it's probably easier to just use CSV or the JSON format for further processing (see ConvertTo-Json
or ConvertTo-Csv
).
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments