PowerShell – Scan Text File for String

email me

# MrNetTek
# eddiejackson.net
# 1/13/2022
# free for public use
# free to claim as your own

$Path = "C:\PowerShell\test.txt"
$Content = (Get-Content -Path $Path | Select-String -Pattern 'Eddie-PC').Matches.Success
if ($Content)
    {  
        #ADD MORE CODE HERE
        Write-Host "Eddie-PC found!"
        Write-host "exiting..."
        Start-Sleep 3
        Exit        
    }
else
    {
        #ADD MORE CODE HERE
        Write-Host "Eddie-PC not found!"
        Write-host "exiting..."
        Start-Sleep 3
        Exit
}