vendredi 3 juillet 2020

modify result of an if in a foreach loop in an attempted result powershell

Hey guys I'm you'll think this is a joke

I've made an if statement like this

$fin = $list.UF6E8_CANAL -match "ML"
if ($list.UF6E8_CANAL -match "ML"){1}
else {0}

Wich works as it is, but as soon as I call it like

write-output "<Index Nom=`"ALERTE_MAIL`" Valeur=`"$fin`"/>"

It becomes true or false

Any idea to get my right result wich should be 1 or 0?

As well another thing, my if is positionned at the beginning of my loop and he answer me with 1 or 0

$boucle = foreach ($list in $liste)

{
$fin = $list.UF6E8_CANAL -match "ML"
if ($list.UF6E8_CANAL -match "ML"){1}
else {0}

write-output "       <Index Nom=`"ALERTE_MAIL`" Valeur=`"$fin`"/>"
}

And so when i introduce him in the loop he answers me with the right answer (0 or 1) But when i call the variable $fin it becomes true or false (i want him to be 1 or 0) And also i would like to hide the result of the first call

Any idea?

Aucun commentaire:

Enregistrer un commentaire