If statement checking for class inputs

33 Views Asked by At

I'm currently still learning, but am working on a small and simple script. I'm attempting to check the user inputs to ensure they match the desired values of the defined variables. The script works fine, just not quite how I want it to. It essentially confirms the if statement as True so long as atleast one of the conditions is met. I'm wanting it to do the opposite, which is throw a False if ANY of those conditions are not True. Thank you for the help ahead of time. I'm still learning, and practicing.

  class Devices {
    [string]$Brand
    [string]$Type
    [int]$zone
   }

$Device1 = [Devices]::new()

$Device1.Brand = Read-Host "Please Enter The Brand"
$Device1.Type = Read-Host "Please Enter The Device Type"
$Device1.zone = Read-Host "Please Enter The Device's Zone"

if (($Device1.Brand -eq "Cisco") -and ($Device1.Type -eq "Switch") -and ($Device1.zone -eq "2" -or "3"))
    {
        Write-Host "Thank You"
    }
    
    else
        {
        Write-Host "That is not a supported device"
        }
0

There are 0 best solutions below