I have multiple checks in an if condition and if any one of them fails status should be failed. For this what I have now is multiple if statements comparing each value to something so that script can notify what exactly failed. Is there a way that I can put these condition in an and criteria in if statement and determine which match failed
if ($a -eq "apple")
{
Write-Host "My fruit is apple"
}
else
{
Write-Host "My fruit is not apple
}
if ($b -eq "banana")
{
Write-Host "My fruit is banana"
}
else
{
Write-Host "My fruit is not banana"
}
If I want to minimize if statements I can write
if (($b -eq "banana") -and ($a -eq "apple"))
{
Write-Host "My fruit is banana and apple"
}
else
{
Write-Host "Match failed for $a or $b"
}
In this if $b is banana but $a is not apple it will enter else part but how do I tell it $a that does not match. I need to know only criteria that is not satisfied
Aucun commentaire:
Enregistrer un commentaire