3

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:\> 
Anthony Neace
  • 25,013
  • 7
  • 114
  • 129

2 Answers2

3

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.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • 1
    Thank you very much. That got rid of the garbage! – C Administrative Share Mar 10 '14 at 21:44
  • Interestingly `select` keyword also works which was present before your recent edit. Are `select` and `Select-Object` aliases or powershell version specific? – RBT Jul 13 '17 at 09:06
  • 1
    @RBT `select` is an alias for `Select-Object` in all PowerShell versions. – Ansgar Wiechers Jul 13 '17 at 09:07
  • `select` is much more intuitive and friendly though specially if someone has worked in T-SQL or LINQ in C#) – RBT Jul 13 '17 at 09:08
  • You may feel that way, but aliases are primarily meant to reduce the amount of typing in an interactive console. It's not recommended to use aliases in scripts, b/c depending on the actual environment they may or may not be present at execution time. That's why I decided to expand aliases when I come across old answers of mine where I used aliases instead of full cmdlet names. – Ansgar Wiechers Jul 13 '17 at 09:11
  • ohh. That's a very good reason for your edit then. I just edited your answer and you might want to expand the note I've added for why you don't use aliases in ps scripts. It is very good piece of information that you might want to add in your post. – RBT Jul 13 '17 at 09:14
0

Not sure exactly if this is what you want but give this a try. This will only display the "Unique" driver versions. This will get rid of the dupe entrys

Get-WmiObject Win32_videoController | Where {$_.Name -like "Nvidia*"} | Select-Object DriverVersion -Unique | Format-Table -HideTableHeaders
HiTech
  • 913
  • 1
  • 16
  • 34