Counting the number of occurrences of a string or file in PowerShell
I always forget how to do this, and Aleksandar Nikolić posted a really beautiful answer on Powershell.com
For a file:
1-split (Get-Content .\test.txt | Out-String) |
2Where-Object { $_ -eq "test" } | Measure-Object |
3Select-Object -exp count
For a string:
1$html.content -split "FeedbackItemSummaryModulePanel" |
2Measure-Object | Select-Object -Exp Count