PowerTip of the Day, from PowerShell.com:
Creating Your Own Get-Driver Tool
Some code snippets are really valuable, so you should turn them into functions to keep around as new PowerShell commands. Here's a sample function:
function Get-Driver {
param(
$Keyword = '*'
)
$col1 = @{Name='File Name'; Expression={ Split-Path $_.Path -Leaf } }
driverquery.exe /v /FO CSV |
ConvertFrom-CSV |
Select-Object 'Display Name', 'Start Mode', 'Paged Pool(bytes)', $col1 |
Where-Object { ($_ | Out-String -Width 300) -like "*$Keyword*" }
}
You now have a function called Get-Driver which lists you all drivers. With just one parameter, you can also easily filter the driver list:
PS> Get-Driver mount
Display Name Start Mode Paged Pool(bytes) File Name
------------ ---------- ----------------- ---------
Mount Point Manager Boot 65.536
WIMMount
PS> Get-Driver disable
Display Name Start Mode Paged Pool(bytes) File Name
------------
CD/DVD File Syst... Disabled 69.632
Crcdisk filter D... Disabled 4.096
udfs
Winsock IFS Driver Disabled 12.288
It is a grep-like filter feature which returns all drivers that have your keyword in one of its properties.
Thanks
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.