title: How to enter text into an input field through Power Shell?
body: <p>Here is a PowerShell script to trigger Internet Explorer, open LinkedIn login page and enter some text in the username text field.</p>
  
  <pre><code>$ie = New-Object -Com "InternetExplorer.Application"
  $ie.Navigate("www.linkedIn.com")
  $ie.Visible = $true
  
  $doc = $ie.document
  $usernameElement = $doc.getElementByTagName("input") | Where-Object {$_.id = "session_key-login""}
  $usernameElement.Click()
  
  Get-Process iexplore | Foreach-Object {$_.CloseMainWindow()}
  </code></pre>
  
  <p>Unfortunately, I keep getting the following error:</p>
  
  <pre><code>You cannot call a method on a null-valued expression.
  At C:\Users\Pinku\Desktop\Untitled1.ps1:7 char:23
  + $usernameElement.Click &lt;&lt;&lt;&lt; ()
  + CategoryInfo          : InvalidOperation: (Click:String) [], RuntimeExcepti 
  on
  + FullyQualifiedErrorId : InvokeMethodOnNull
  </code></pre>
  
  <p>I have tried but have not been able to alleviate myself from this issue.Please suggest!</p>