title: PowerShell programmatically set input field by name in IE
body: <p>Related: <a href="https://stackoverflow.com/questions/17049203/powershell-download-or-save-source-code-for-whole-ie-page">Powershell: Download or Save source code for whole ie page</a></p>
  
  <p>The input fields I need to programmatically drive do not have an ID, so I'm trying to set them with the form name instead.</p>
  
  <p>In the IE F12 developer console, this command works:
      <code>document.forms["loginForm"].elements["_ssoUser"].value = "someone's username"</code></p>
  
  <p>But in PowerShell, this command fails:
      <code>$ie.document.forms["loginForm"].elements["_ssoUser"].value = "$username"</code></p>
  
  <p>The error is "cannot index into a null array".</p>
  
  <p><img src="https://i.stack.imgur.com/4aLuV.png" alt="IE console shows working command, but fails when PowerShell attempts to send the same to the scripted instance of IE."></p>