Skip to content

Instantly share code, notes, and snippets.

@snerpton
Created March 17, 2016 11:15
Show Gist options
  • Save snerpton/6bb02932e0fc0caab730 to your computer and use it in GitHub Desktop.
Save snerpton/6bb02932e0fc0caab730 to your computer and use it in GitHub Desktop.
Scan file for number of text matches
$process = Get-Process -Id $pid
$process.PriorityClass = 'BelowNormal'
#$process.PriorityClass = 'Idle'
function GetOccurrenceInFile($1)
{
$date = Get-Date
$fileDate = ((Get-Item $1).Basename).replace('u_ex', '')
Write "$date --- $1.FullName"
$number = (get-content $1 | select-string -pattern "/cirtix").length
"$fileDate, $number" | Out-File c:\tmp\test.txt -Append
Write "Hello --- $fileDate --- $number"
}
$Path = "C:\tmp\LogFiles"
$files = Get-ChildItem $path\*.log
#ForEach ($file in $files | select -First 5) {
ForEach ($file in $files) {
#c:\outputfiles\ldump.exe $file.fullName | Out-File c:\outputfiles\test9.txt -Append
#"=======End of Batch========" | Out-File c:\outputfiles\test9.txt -Append
#Write $file.FullName
GetOccurrenceInFile $file
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment