I may be missing some basic concept about if statement or condition based operations in powershell, but i got stuck in following code appears to be not working in right way:
$computername= "owvpos7.ykbdmz.com"
if(($computername -ne "owvpos5.ykbmdz.com") -and ($computername -ne "owvpos6.ykbmdz.com") -and ($computername -ne "owvpos7.ykbmdz.com") -and ($computername -ne "owvpos8.ykbmdz.com")) {
Write-Host 'In'
} else {
Write-Host 'Out'
}
I expect the above code should print out 'Out' but it prints 'In'.
The behavior i try to construct is to not go in if block when $computername variable is equal to one of predefined names.
Aucun commentaire:
Enregistrer un commentaire