2014-04-07 7 views
6
$url = "https://example.sharepoint.com/" 
$username="[email protected] " 
$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(); 

Attualmente ho questo codice che viene eseguito in PowerShell (non Powerpoint di SharePoint) per prima cosa apre Internet Explorer e poi accede al login e alla password.Utilizzo di Powershell per aprire internet explorer e accedere a sharepoint

Ciò che non è stato possibile fare è ottenere il codice per selezionare il pulsante di accesso. Qualcuno sa quale valore dovrei avere per ottenere il pulsante da selezionare?

Grazie

Dovrebbe essere questa parte del codice. $ Ie.Document.getElementById ("cred_sign_in_button") Fare clic su().;

Questo è il codice sorgente per il pulsante di accesso.

 <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">Sign in</span> 
        <div id="recover_container" class="subtext smalltext"> 
      <span> 

risposta

8

Per fare ciò è necessario scaricare il plug-in WASP per PowerShell.

http://wasp.codeplex.com/

Dopo che il seguente codice farà il trucco.

$url = "https://example.sharepoint.com/" 
$username="[email protected] " 
$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 

Import-Module WASP 
$ie = Select-Window IEXPLORE | Set-WindowActive 
$ie | Send-Keys "{TAB}" 
$ie | Send-Keys "{TAB}" 
$ie | Send-Keys "{TAB}" 
$ie | Send-Keys "{TAB}" 
$ie | Send-Keys "{TAB}" 
$ie | Send-Keys "{TAB}" 
Start-Sleep -Milliseconds 1000 
$ie | Send-Keys "{ENTER}" 
Problemi correlati