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 Computers

System One System Two

  • Operating System
    Windows 8.1 Industry Pro x64
    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 x2
    Other Info
    https://www.cnet.com/products/hp-pavilion-elite-hpe-250f/
  • Operating System
    Windows 2012 R2 Data center/Linux Mint
    Manufacturer/Model
    Dell Poweredge T140
    CPU
    i3 9100 3.6GHz, 8M cache, 4C/4T
    Memory
    8GB 2666MT/s DDR4 ECC UDIMM
    Screen Resolution
    1680x1050
    Hard Drives
    1 TB & 360 GB x2
    Other Info
    https://www.dell.com/en-us/work/shop/productdetailstxn/poweredge-t140?~ck=bt
Back
Top