我有以下代码,它会登录到我经常使用的网站:
param(
[string]$interval
)
function Refresh-WebPages {
"Neptun refresh every $interval seconds."
"press any key to exit."
$shell = New-Object -ComObject Shell.Application
do {
Start-Sleep -Seconds $interval
'Refreshing'
$shell.Windows() |
Where-Object { $_.Document.url } |
ForEach-Object { $_.Refresh() }
} until ( [System.Console]::KeyAvailable )
[System.Console]::ReadKey($true) | Out-Null
}
$username = "asd";
$SecureString = Read-Host "password" -AsSecureString;
$BSTR =
[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString);
$PlainPassword =
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
$IE=new-object -com internetexplorer.application;
$IE.navigate2("https://hallgato.neptun.elte.hu/login.aspx");
$IE.visible=$true;
While ($IE.Busy -eq $true) {Start-Sleep -Milliseconds 500}
$IE.Document.getElementById('user').value = "$username";
$IE.Document.getElementById('pwd').value = "$PlainPassword";
($IE.document.getElementById('btnSubmit') |select -first 1).click();
Refresh-WebPages -interval
我想检查登录是否失败或成功。我能否以某种方式检查URL是否不同?