Skip to content

Instantly share code, notes, and snippets.

@KirillPashkov
Last active November 22, 2021 17:11
Show Gist options
  • Save KirillPashkov/03f0ac0b0ccbdaa3f83ac4291264fb22 to your computer and use it in GitHub Desktop.
Save KirillPashkov/03f0ac0b0ccbdaa3f83ac4291264fb22 to your computer and use it in GitHub Desktop.
$lookup = '***'
Out-File -FilePath C:\temp\results.txt -InputObject $lookup -Encoding utf8 -Force -Append
gci -File 'C:\temp\1' -Recurse -Filter '*.*' -Exclude '*.zip'|
select -exp FullName | % {
$f = gc $_; $l=1
foreach($r in @($f.Split("`n"))){
#if ($r.Length -gt 0 -and $r -match $lookup){Write-Host $("File: {0}`tLine: {1}`tString: {2}" -f $_,$l,$r) -b Black -f Green}; $l++
if ($r.Length -gt 0 -and $r -match $lookup){Out-File -FilePath C:\temp\results.txt -InputObject $("[File: {0}][Line: {1}][String: {2}]" -f $_,$l,$r) -Encoding utf8 -Force -Append }; $l++
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment