Showing posts with label ConvertFrom-CSV. Show all posts
Showing posts with label ConvertFrom-CSV. Show all posts

Monday, January 9, 2012

Finding More Driver Information using PowerShell

 

PowerTip of the Day, from PowerShell.com:

 

Finding More Driver Information

In a previous tip you learned how you can convert raw CSV data from a console application such as driverquery.exe into real PS objects. Let's play some more.

Since the CSV data only returns the complete path to a driver (which is too long to display without being truncated), let's add a "calculated property". That's a hash table with two keys: Name and Expression.

The script block in Expression takes the long path name and extracts just the file name. Now we get valuable driver information that - due to its object nature - can easily be sorted as well:

PS> $col1 = @{Name='File Name'; Expression={ Split-Path $_.Path -Leaf } }

PS> driverquery.exe /v /FO CSV | ConvertFrom-CSV | Select-Object 'Display Name',

 'Start Mode', 'Paged Pool(bytes)', $col1 | Sort-Object 'Display Name'

 

Display Name                   Start Mode                            Paged Pool(bytes   File Name

------------                   ----------                            -----------------        ---------

ACPI-Energieanze... Manual                                    4.096                                         acpipmi.sys

adp94xx                                   Manual                                    0                                                   adp94xx.sys

adpahci                                   Manual                                    0                                                   adpahci.sys

adpu320                                   Manual                                    0                                                   adpu320.sys

Agere Systems So... Manual                                    20.480                                    agrsm64.sys

aliide                                     Manual                                    0                                                   aliide.sys

AMD K8 Processor... Manual                                    28.672                                     amdk8.sys

AMD Processor Dr... Manual                                    28.672                                     amdppm.sys

amdide                                     Manual                                    0                                                   amdide.sys

amdsata                                  Manual                                    0                                                   amdsata.sys

(...)

 

Thanks

Finding Driver Information using PowerShell

 

PowerTip of the Day, from PowerShell.com:

driverquery.exe returns all kinds of information about installed drivers, but the information seems a bit useless at first:

PS> driverquery.exe /V

 

Module Name     Display Name                  Description                   Driver Type         Start Mode State          St

============ ================  ================== ============= ========== =======  ==

1394ohci           OHCI-konformer 1394-Ho OHCI-konformer 1394-Ho Kernel    Manual         Stopped     OK
20.11.2010 11:44:56    C:\Windows\system32\drivers\1394ohci.sys         4.096

This console application does support a parameter called /FO CSV. This formats the information as a comma-separated list:

PS> driverquery.exe /v /FO CSV

"Module Name","Display Name","Description","Driver Type","Start Mode","State","S

tatus","Accept Stop","Accept Pause","Paged Pool(bytes)","Code(bytes)","BSS(bytes

)","Link Date","Path","Init(bytes)"

"1394ohci","OHCI-konformer 1394-Hostcontroller","OHCI-konformer 1394-Hostcontrol

ler","Kernel ","Manual","Stopped","OK","FALSE","FALSE","4.096","200.704","0","20

.11.2010 11:44:56","C:\Windows\system32\drivers\1394ohci.sys","4.096"

Now here's the scoop: Powershell can not only read the results from console application. When the output is CSV, it can even convert the raw text automagically into objects. So, with just one line, you get tremendous information about drivers (thanks to Stephen Owen for pointing us to this):

PS> driverquery.exe /v /FO CSV | ConvertFrom-CSV | Select-Object 'Display Name',

 'Start Mode', 'Paged Pool(bytes)', Path

 

Display Name                     Start Mode               Paged Pool(bytes)       Path

------------                     ----------                -----------------      ----

OHCI-konformer 1... Manual                         4.096                                       C:\Windows\syste...

Microsoft ACPI-T... Boot                              90.112                                     C:\Windows\syste...

ACPI-Energieanze... Manual                         4.096                                       C:\Windows\syste...

(...)

 

Thanks