title: Using Powershell to open internet explorer and login into sharepoint
body: <pre><code>$url = "https://example.sharepoint.com/" 
  $username="JohnDoe@example.com " 
  $password="Password" 
  
  
  $ie = New-Object -com internetexplorer.application; 
  $ie.visible = $true; 
  $ie.navigate($url);
  
  
  while ($ie.Busy -eq $true) 
  { 
      Start-Sleep -Milliseconds 1000; 
  } 
  $ie.Document.getElementById("login").value = $username 
  $ie.Document.getElementByID("Passwd").value=$password 
  $ie.Document.getElementById("cred_sign_in_button").Click();
  </code></pre>
  
  <p>Currently I have this code which runs in powershell (not sharepoint powershell) it first opens Internet explorer and second enters the login and password. </p>
  
  <p>What I havent been able to do though is to get the code 
  to select the sign in button. Does anyone know what value I should have to get the button to select?</p>
  
  <p>Thanks</p>
  
  <p>It should be this part of the code.   $ie.Document.getElementById("cred_sign_in_button").Click();</p>
  
  <p>This is the source code for the sign in button. </p>
  
  <pre><code>      &lt;span id="cred_sign_in_button" tabindex="11" onclick="Post.SubmitCreds();return false;"
              class="button normaltext cred_sign_in_button refresh_domain_state" role="button"&gt;Sign in&lt;/span&gt;
                      &lt;div id="recover_container" class="subtext smalltext"&gt;
            &lt;span&gt;
  </code></pre>