title: Array of variables in PowerShell has null members
body: <p>I have a PowerShell script, where I want to make sure certain variables have value before proceeding.</p>
  
  <p>So I have the following:</p>
  
  <pre><code>$dataRow = $sheet.Cells.Find($country).Row
  $serverCol = $sheet.Cells.Find($serverString).Column
  $databaseCol = $sheet.Cells.Find($databaseString).Column
  $userCol = $sheet.Cells.Find($userString).Column
  $passwordCol = $sheet.Cells.Find($passString).Column
  $partnerCol = $sheet.Cells.Find($partnerString).Column
  
  #All variables in this array are required. If one is empty - the script cannot continue
  $requiredVars = @($dataRow, $serverCol, $databaseCol, $userCol, $passwordCol, $partnerCol)
  </code></pre>
  
  <p>But when I foreach over the array like so:</p>
  
  <pre><code>foreach ($var in $requiredVars)
  {
      Write-Host DataRow = ($dataRow -eq $var)
      Write-Host ServerCol = ($serverCol -eq $var)
      Write-Host DatabaseCol = ($databaseCol -eq $var)
      Write-Host UserCol = ($userCol -eq $var)
      Write-Host PasswordCol = ($passwordCol -eq $var)
      Write-Host PartnerCol = ($partnerCol -eq $var)
      if ($var -eq $null)
      {
          [System.Windows.Forms.MessageBox]::Show("No data found for given string!")
          $excel.Quit()
          return
      }
  }
  </code></pre>
  
  <p>I always get the MessageBox. I added the "Write-Host" part to see the value of each variable, then changed it to see which variable was null but all variables have values in them and all the checks you see here return "False".</p>
  
  <p>I'd like to know what I'm doing wrong and if the <code>$requiredVars</code> array only copies values, not references or something.</p>