Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove extra lines from Get-WMIObject output powershell

Tags:

powershell

wmi

I am running the following query to get the video driver version number

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

It returns the data I want plus about 4 extra lines. One before the output and 3 after. It doesn't look like it's going to show up properly in the post.

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

9.18.13.3250                                                                                                                                                                                  



PS F:\> 
like image 878
C Administrative Share Avatar asked Feb 03 '26 03:02

C Administrative Share


1 Answers

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

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

Note: You can also use the aliases gwmi for Get-WmiObject and select for Select-Object. Beware, though, that aliases may not be present during script execution depending on your environment. They're basically a means to reduce the amount of typing required in an interactive console.

like image 160
Ansgar Wiechers Avatar answered Feb 06 '26 02:02

Ansgar Wiechers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!