title: How to display error from comparison statement
body: <p>I am trying to get in error message to pop when certain conditions do not match. The information is browsing through a csv file.</p>
  
  <p>My issue is one of my statements work but does not display anything. Here is my condition statement.</p>
  
  <pre><code>$spellingerror = $hostid -notin $data."Host ID"
  $existsnotopen = $hostid -eq $data."Host ID" -and $_.Status -ne $data.Open
  
    if ($spellingerror) 
  {Write-Host -foregroundcolor Green "Host does not exist"}
  
    elseif ($existsnotopen)
  {Write-Host -foregroundcolor Green "Host exists and is not open"}
  
    else
     {$data | Sort-Object {[DateTime]$_."Last Modified"} |   Where-Object
     {$_."Host ID" -eq $hostid -and $_."Status" -eq "Open"} | 
     Select -First 1 -ExpandProperty "Last Modified"}
  </code></pre>
  
  <blockquote>
    <p>this is the issue</p>
  </blockquote>
  
  <pre><code>elseif ($existsnotopen)
  {Write-Host -foregroundcolor Green "Host exists and is not open"}
  </code></pre>
  
  <p>it will not output Host exists and is not open, I do not get an error message.</p>
  
  <p><code>$hosted</code> is a string so I see why I cant use <code>-eq</code>. I changed it to <code>-match</code>.
  I used <code>$data."Host ID"</code> because I wanted it to search the whole spreadsheet like I did in <code>-notin $data."Host ID"</code>. I tried using what you tried because my status are either "Open" or "not applicable". Here is sample data.</p>
  
  <pre><code>      Hostname      Status
        LOG            Open
        LOG           Not Applicable
        NETMAN         Open
        HD             Open
        NETMAN        Not Applicable
        LOG           Not Applicable
  </code></pre>