Search-OSDriverContent.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<#
.LINK
 https://www.osdeploy.com/psmodule/osdrivers/
.SYNOPSIS
 Searches in INF files for a text string
.DESCRIPTION
 Searches in INF files for a text string
.PARAMETER Path
 Directory to search for INF files
.PARAMETER Content
 Text string to search
.PARAMETER Files
 Files to Include. Default is *.inf
.EXAMPLE
 Search-OSDriverContent -Path C:\DeploymentShare\OSDrivers -Content "VEN_8086&DEV_1902"
 Searches in all INF files for "VEN_8086&DEV_1902". Results in Gridview
.EXAMPLE
 Search-OSDriverContent -Path C:\DeploymentShare\OSDrivers -Files *.txt -Content "VEN_8086&DEV_1902"
 Searches in all TXT files for "VEN_8086&DEV_1902". Results in Gridview
.NOTES
 NAME:    Search-OSDriverContent.ps1
 AUTHOR:    David Segura, david@segura.org
 BLOG:    http://www.osdeploy.com
 CREATED:    02/18/2018
 VERSION:    1.1.0.2
#>


function Search-OSDriverContent
{
    [CmdletBinding()]
    Param (
        [Parameter(Mandatory=$True)]
        [string]$Path,
        [string[]]$Files = '*.inf',
        [string]$Content
    )
Get-ChildItem "$Path" -Recurse -Include $Files -File | Select-String $Content | Select Path, Filename, LineNumber, Line | Out-Gridview -Title 'Search-OSDriverContent Results'
}