0

I am trying to get the list of 3rd party drivers installed on a Windows 8 machine.

gwmi win32_systemdriver| ? ((Get-ItemProperty $psitem.pathname).VersionInfo).companyname -NotLike *microsoft*

Error : Get-ItemProperty : Cannot bind argument to parameter 'Path' because it is null.

Is there a one-liner way getting around this problem.

Ayan Mullick
  • 67
  • 2
  • 11
  • 38
  • Can't you just filter out any drivers which does not have a value in the `pathname` property? Like so: `gwmi win32_systemdriver | where pathname` followed by the rest of your filtering. – Robert Westerlund Mar 11 '14 at 00:10
  • @Robert Every system driver has a pathname. `gwmi win32_systemdriver|select -Property pathname` – Ayan Mullick Mar 11 '14 at 06:18
  • On one of my computers, I had three entries which had an empty `pathname`. Also, if all of them would have a `pathname` you wouldn't receive the error message you write in your question (it is very explicit in showing that there isn't a pathname since it says `Cannot bind argument to parameter 'Path' because it is null.`). Try `gwmi win32_systemdriver | Where pathname | ? ((Get-ItemProperty $psitem.pathname).VersionInfo).companyname -NotLike *microsoft*` and see if it makes a difference. – Robert Westerlund Mar 11 '14 at 07:22
  • @Robert Nope, Same error. `Get-ItemProperty : Cannot bind argument to parameter 'Path' because it is null.` – Ayan Mullick Mar 11 '14 at 08:52
  • 1
    Sorry, just reread your statement. Use the scriptblock syntax for your Where statement: `gwmi win32_systemdriver | ? { (Get-ItemProperty $psitem.pathname).VersionInfo.companyname -NotLike "*microsoft*"}`. On the computer where I have entries with empty pathnames I also have to add the `where pathname` to get it to run successfully, but on another computer this wasn't necessary. – Robert Westerlund Mar 11 '14 at 09:13
  • Funny; I thought you didn't need the scriptblock anymore with V3. I Finalized on. `gwmi win32_systemdriver|?{(Get-ItemProperty $psitem.pathname -ErrorAction Ignore).VersionInfo.companyname -NotLike "*microsoft*"}|sort state|ft -AutoSize` Thank you @Robert. Wonder if there in an inline way of printing out the `Companyname` too or do I need to write a whole script with a loop. – Ayan Mullick Mar 11 '14 at 09:55
  • 1
    Say that you want to show the `Status`, `State`, `Name` and `CompanyName` properties for each of the found items, you could do something like the following: `gwmi win32_systemdriver | select *, @{ N='CompanyName';E={ (Get-ItemProperty $_.pathname -ErrorAction Ignore).VersionInfo.companyname }} | Where companyname -NotLike "*microsoft*" | sort state | ft Status, State, Name, ExitCode, CompanyName`. Best of luck! – Robert Westerlund Mar 11 '14 at 12:39
  • @Robert, Perfect. You could post that as an answer so I can accept it. And Thanks again. – Ayan Mullick Mar 11 '14 at 18:12

1 Answers1

0

Answer moved from comment discussion on question:

Say that you want to show the Status, State, Name and CompanyName properties for each of the found items, you could do something like the following:

gwmi win32_systemdriver | 
    select *, @{ N='CompanyName';E={ (Get-ItemProperty $_.pathname -ErrorAction Ignore).VersionInfo.companyname }} | 
    Where companyname -NotLike "*microsoft*" | 
    sort state | 
    ft Status, State, Name, ExitCode, CompanyName.
Robert Westerlund
  • 4,750
  • 1
  • 20
  • 32