title: Checking if registry value is equal to 1 is not working correctly
body: <p>I have slopped together bits of PowerShell to remote query a list of machines, stored in a .csv file, for a registry value.  If the registry key's value is equal to '1', the script should then create a text file using the machine's name as the name of the text file.</p>
  
  <p>Everything works great.  The script runs happily without any errors.  The problem is that when I go back and remotely check a targeted registry value, I find that the value isn't 1.  The script is simply creating a file for every line in the .csv.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>EDIT*** I found <strong><em>a</em></strong> problem  I had a typo in the $key variable for the registry path.  7/17/2013 2:21p</p>
  
  <pre><code>$File = Import-Csv 'c:\temp\machines.csv'
  
  foreach ($line in $file)
  {
    $machinename = $line.machinename
    trap [Exception] {continue}
    $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine",$MachineName)
    $key = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon"
    $regkey = ""
    $regkey = $reg.opensubkey($key)
    $keyValue = ""
    $keyValue = $regKey.GetValue('AutoAdminLogon')
  
    if ($keyValue = "1")
    {
      try
      {
        $textFile = New-Item -Path "c:\temp\autologin" -Name $MachineName -ItemType "File"
      }
      catch
      {
        $msg = $_
        $msg
      }
    }
    $Results = $MachineName , $keyValue
    Write-host $Results
  
    #Output Below Here:
  }
  </code></pre>