title: Powershell: How to press a button on a web page if you don't know the button ID
body: <p>I'm trying to fill in my username and password on a certain web page and then the press the "sign-in" button, all automatically via Powershell.</p>
  
  <p>The problem is that I cannot find the ID of the sign-in button in the html source code. </p>
  
  <p>I have tried to use the command:</p>
  
  <pre><code>$link = $ie.Document.getElementsByTagName('A') | where-object {$_.innerText -match 'sign in'}
  </code></pre>
  
  <p>but this didn't worked either. </p>
  
  <p>Any thoughts which PS command to use if I want to press the 'sign in' button?</p>
  
  <p>The HTML code is as follows:</p>
  
  <pre><code>&lt;div class="login"&gt;
      &lt;div class="content"&gt;
          &lt;div class="subsection-1"&gt;Sign in or create a &lt;a id="ctl00_HeaderUserControl_LoginUserControl_hypNewAccount" href="/authentication/registerprovider.aspx?"&gt;new account&lt;/a&gt;&lt;/div&gt;
          &lt;div class="subsection-2"&gt;
              &lt;span class="navy bold"&gt;What is your email address?&lt;/span&gt;
              &lt;div class="indent"&gt;
                  &lt;span class="bold"&gt;Email:&lt;/span&gt;
                  &lt;input id="loginEmail" class="text-box" type="text" maxlength="100" tabindex="1" /&gt;
                  &lt;img class="ajax-loader" src="/content/images/research/global/transparent.gif" alt="" /&gt;
              &lt;/div&gt;
              &lt;div class="invalid-email"&gt;&lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="subsection-3"&gt;
              &lt;span class="navy bold"&gt;Do you know your password?&lt;/span&gt;
              &lt;div&gt;
                  &lt;input id="passwordNotKnown" name="passwordSwitch" type="radio" checked="checked" /&gt;
                  &lt;label for="noPassword"&gt;No, I don't know my password or I'm new .&lt;/label&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;input id="passwordKnown" name="passwordSwitch" type="radio" /&gt;
                  &lt;label for="noPassword"&gt;Yes, my password is:&lt;/label&gt;
                  &lt;input id="loginPassword" class="text-box" type="password" maxlength="50" tabindex="2" /&gt;
              &lt;/div&gt;
              &lt;div class="invalid-password"&gt;&lt;/div&gt;
              &lt;div class="error"&gt;&lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="subsection-4"&gt;
              &lt;button type="button" class="login-button greenButton" tabindex="4"&gt;Sign in&lt;/button&gt;
              &lt;a href="javascript:void(0);" class="cancel-link"&gt;Cancel&lt;/a&gt;
              &lt;input id="stayLoggedIn" type="checkbox" tabindex="3" /&gt;
              &lt;label for="stayLoggedIn"&gt;Stay signed in&lt;/label&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="reset-password"&gt;
          &lt;div class="subsection-1"&gt;Would you like to reset your password?&lt;/div&gt;
          &lt;div class="subsection-2"&gt;Choosing &lt;span class="bold"&gt;yes&lt;/span&gt; will reset your password and email a temporary password to: &lt;span class="repeat-email"&gt;&lt;/span&gt;&lt;/div&gt;
          &lt;div class="subsection-3"&gt;
              &lt;div class="center"&gt;
                  &lt;button class="reset-password-button" type="button"&gt;Yes&lt;/button&gt;
                  &lt;button class="do-not-reset-password-button" type="button"&gt;No&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>