Powershell if statement assistance (PS 1.0)

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?
 

My Computer

My Computer

System One

  • Operating System
    Windows 7 Pro & 10 Pro
    Manufacturer/Model
    HP Pavillion Elite HPE-250f
    CPU
    Intel i7 860 Quad core 2.8 ghz
    Memory
    8 gb
    Graphics card(s)
    ATI Radeon HD 5770 1 gb ram
    Monitor(s) Displays
    Alienware 25 AW2521HF
    Screen Resolution
    1920x1080 &1680x1050
    Hard Drives
    1 TB & 500 GB
    Other Info
    https://www.cnet.com/products/hp-pavilion-elite-hpe-250f/
Back
Top