2016-06-14 71 views
1

にログイン情報を入力しようとすると:「HRESULTからの例外:0X800A01B6」PowerShellでエラー私は、このコードは、PowerShellで書かれているFacebookの

Exception from HRESULT: 0x800A01B6 
At line:1 char:1 
+ ($ie.document.getElementsByName("email") |select -first 1).value = $u ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
+ CategoryInfo   : OperationStopped: (:) [], NotSupportedException 
+ FullyQualifiedErrorId : System.NotSupportedException 

$username = "xxxxxx"; 
$password = "xxxxxx"; 
$url = "www.facebook.com/login"; 

$ie = New-Object -com internetexplorer.application; 
$ie.visible = $true; 
$ie.navigate($url); 

($ie.document.getElementsByName("email") |select -first 1).value = $username; 

をそしてそこにある私は、このエラーメッセージを取得するとき

どのような解決策ですか?

ありがとうございました!

+0

これについて自分で研究しましたか?私はpowershellに慣れていないが、エラーは、開いたかっこの最初の文字で構文エラーのように思える? – owler

+0

@owler構文エラーではありません。 '' ''は '.value'の直前で閉じています。私は推測していますが、' NotSupportedException'は '.value'が書き込み可能ではないと信じさせています。 – briantist

答えて

1

IEがまだページを読み込んでいるか、DOMを解析中である可能性があります。ページ要素にアクセスする前にIEがビジーでないのを待ってください。 IEのBusy propertyの簡単なチェックができます。そうですね、

$username="myname" 
$password="mypass" 
$url = "www.facebook.com/login" 
$ie = New-Object -com internetexplorer.application 
$ie.visible = $true 
$ie.navigate($url) 

# Sleep while IE is busy. Check 10 times per second, adjust delay as needed 
while($ie.Busy) { Start-Sleep -Milliseconds 100 } 

# IE is not busy with document anymore, pass credentials and click the logon  
($ie.document.getElementsByName("email") |select -first 1).value = $username 
($ie.document.getElementsByName("pass") |select -first 1).value = $password 
($ie.document.getElementsByName("login") |select -first 1).click() 
関連する問題