user12682332
user12682332

Reputation:

Powershell WMI-Object Select-Object makes 2 blank lines, is there a way to remove the blank lines?

I'm making a list of infomation that i what to display. But anytime i run the line that is needed to show the info, it's gonna place 2 blank lines over the output.

Code looks like this

$Pro = Get-WmiObject -Class win32_processor

$pro | select-Object Name,NumberofCores,NumberOfLogicalProcessors | format-list

Is there something else i can do to make it remove the 2 lines from the output? (Can't show the blank lines because they don't show)

Name : Intel(R)
NumberOfCores : x
NumberOfLogicalProcessors : x

Upvotes: 0

Views: 721

Answers (2)

user12682332
user12682332

Reputation:

The Answer from @leeharvey1 is what was needed.

$pro | Select-Object Name | Format-list| Out-string | ForEach-Object { $_.Trim() 

Upvotes: 1

JimShapedCoding
JimShapedCoding

Reputation: 917

This is the only solution i've could figure to overcome the blank lines issue:

$Pro = Get-WmiObject -Class win32_processor

$pro | select-Object Name,NumberofCores,NumberOfLogicalProcessors | format-list | Out-String | % ($_) {$_.Trim()}

Upvotes: 0

Related Questions