How to remove extra lines from Get-WMIObject output powershell

I run the following query to get the version number of the video driver

Get-WmiObject Win32_videoController | where {$_.Name -like "Nvidia*"} | Format-table -HideTableHeaders DriverVersion 

It returns the data I want, plus about 4 extra rows. One before going out and 3 after. It does not look like it will display correctly in the message.

 PS F:\> Get-WmiObject Win32_videoController | where {$_.Name -like "Nvidia*"} | Format-table -HideTableHeaders DriverVersion 9.18.13.3250 PS F:\> 
+2
powershell wmi
source share
2 answers

If you want to determine the driver version, forget about Format-Table . Just do the following:

 Get-WmiObject Win32_VideoController -Filter "Name LIKE 'Nvidia%'" | Select-Object -Expand DriverVersion 

Note. You can also use gwmi for Get-WmiObject and select for Select-Object . Remember, however, that aliases may not be available at runtime depending on your environment. They are mainly a means of reducing the amount of input required in the interactive console.

+2
source share

Not sure what exactly you want, but give it a try. This will display only Unique versions. This will save you error records.

 Get-WmiObject Win32_videoController | Where {$_.Name -like "Nvidia*"} | Select-Object DriverVersion -Unique | Format-Table -HideTableHeaders 
0
source share

All Articles