2010-11-18 116 views
2

我以前使用http自動登錄過程之前使用http,但相同的代碼不適用於另一個正在使用https(安全協議)的網站。所以我不確定我是否需要做一些額外的工作才能使用PowerShell來登錄該網站。是否有可能使用powershell登錄https站點(安全http)

編輯:從評論


$ie = New-Object -ComObject "internetExplorer.Application" 
$ie.Visible = $true 
$ie.Navigate("secure.websitename.com/xyz/login.aspx";) 

while ($ie.Busy -eq $true){Start-Sleep -Milliseconds 1000;} 

Write-Host -ForegroundColor Magenta "Attempting to login"; 

$doc = $ie.Document 
$LoginName = $doc.getElementsByName("txtUserName") 

$LoginName.value = "username" 
$txtPassword = $doc.getElementsByName("txtUserPass") 

$txtPassword = "password" 
$btnLogin = $doc.getElementsByName("cmdLogin") 
+0

您是否收到任何錯誤消息?你正在使用哪些命令? – Thilo 2010-11-18 01:46:53

+0

在PowerShell中創建資源管理器對象後,我嘗試導航到「https://www.xyz.com」,並且資源管理器對象不包含任何值。它也不是零。之後,如果我嘗試讀取文檔對象,它是空的。 – user423487 2010-11-18 01:53:20

+0

我使用以下代碼$ ie = New-Object -ComObject「internetExplorer.Application」 $ ie.Visible = $ true $ ie.Navigate(「https://secure.websitename.com/xyz/login.aspx」 ) while($ ie.Busy -eq $ true){Start-Sleep -Milliseconds 1000;} Write-Host -ForegroundColor Magenta「正在嘗試登錄」; $ DOC = $ ie.Document $的LoginName = $ doc.getElementsByName( 「txtUserName」) $ LoginName.value = 「username」 的 $ txtPassword = $ doc.getElementsByName( 「txtUserPass」) $ txtPassword = 「密碼」 $ btnLogin = $ doc.getElementsByName(「cmdLogin」) – user423487 2010-11-18 01:55:51

回答

0

添加代碼,您將需要在$ie.Navigate包括 「https」 開頭。我也相信,如果您管道$ie>Get-Member有一個Credentials屬性,您可以使用它來傳遞用戶名和密碼。我現在沒有在我面前安裝PowerShell,但之前已經使用https網站玩過這個。