title: Powershell script variable treats comparison operations differently
body: <p>I have an odd issue where a variable that is part of an if statement is not performing a comparison to a value as expected</p>
  
  <p>The value is in a CSV file. It is a number, not a string so it should work fine. If the value comparison is set to <code>-eq "0"</code> it will print out the file entries that have only zero. If I use <code>-gt</code> it lists only the values entries not zero. So far so good.</p>
  
  <p>If I use <code>-le</code> or <code>-lt</code> all file entries will get printed. If I use multiple comparisons such as <code>-gt "0"</code> and <code>-lt "5"</code> this also does not work - it prints out all values (except those equal to zero of course). I'm at a loss how to get the code to work properly (ignore <code>Write-host</code>, that is just so I can see the output).</p>
  
  <p>I'm using <code>Foreach</code> because I'll never have more than about 10-20 entries, otherwise I'd go with <code>Foreach-Object</code>. Code details are below:</p>
  
  <pre><code>$extractFile = "C:\SrvInventory\DBLoginChk.csv"
  $passwdexp = 5
  $DBdetails = Import-csv $extractfile
  Foreach ($DBCreds in $DBdetails) {
      If (($DBCreds.DaysUntilExpiration -gt "0") -and 
          ($DBCreds.DaysUntilExpiration -le $passwdexp)) {
          $Expdt = $($DBCreds.DaysUntilExpiration)
          $DBName = $($DBCreds.LoginName)
          $Emailaddr = $DBName+'@'+'myplace.com'
          Write-host $Expdt
      }
  }
  </code></pre>
  
  <p>File contents look like this:</p>
  
  <pre><code>"LoginName","DaysUntilExpiration"
  "spot","35"
  "pup","22"
  "cat","21"
  "rhino","3"
  "camel","1"
  "Bull","0"
  "warthog","0"
  "GViewer","0"
  "grandrapids","0"
  </code></pre>