mardi 24 novembre 2020

Powershell function not giving result on false

I have a function to check if a match is false or true. It works on true but on false it doesn't return anything. I've tried testing it by echoing result at the start in function, which it says false but doesn't work in if statement. Any ideas on how to fix it?

function check($match,$result){
    echo $match
    if ($match -eq $false){
        return $result="Not In Log"
    }
    elseif ($match -eq $true) {
        return $result=$matches.values
    }}

running code with true works but false its just empty result from return statement. clearly the echo at the start shows that it is false

$item='src="test time"'
check(($item -match '(?<=srcdsfd=)\S+'),$source)
False
check(($item -match '(?<=src=)\S+'),$source)
True
"test

Aucun commentaire:

Enregistrer un commentaire