Maximus0811
New Member
Hi guys,
I'm new to powershell and currently am using this script to search a particular flile for a string and then display the number of matches. Rather than display the number of matches, I'm interested in using the count in an if count -eq some number [do something] else [do something]. What is my script missing? I've tried a few different things, but my syntax is way off.
The existing script, which displays the total count of ABC works and s as follows.
$word = "ABC"
Get-ChildItem *.config |
Where-Object {Select-String "\b$word\b" $_.fullname -quiet} |
Select-Object FullName, @{name = 'Count';
expression = {@((Get-Content $_.fullname |
Out-String).split() -match "\b$word\b").count}} |
Format-Table -auto
Like I said, rather than displaying the count, I want to use that 'count' in an else/if statement.
Can someone help?
I'm new to powershell and currently am using this script to search a particular flile for a string and then display the number of matches. Rather than display the number of matches, I'm interested in using the count in an if count -eq some number [do something] else [do something]. What is my script missing? I've tried a few different things, but my syntax is way off.
The existing script, which displays the total count of ABC works and s as follows.
$word = "ABC"
Get-ChildItem *.config |
Where-Object {Select-String "\b$word\b" $_.fullname -quiet} |
Select-Object FullName, @{name = 'Count';
expression = {@((Get-Content $_.fullname |
Out-String).split() -match "\b$word\b").count}} |
Format-Table -auto
Like I said, rather than displaying the count, I want to use that 'count' in an else/if statement.
Can someone help?