Powershell - 脚本登录

Powershell - Scripting login

我正在尝试从网络时钟自动生成时间卡报告,由于某种原因,该时钟具有电子邮件提醒但无法通过电子邮件发送时间卡 (smh)。

这是我正在查看的内容:

<form method="post" action="" name="formMain">
<div><label for="username">Username/PIN</label> <input id="username" type="text" name="username" value="" autocapitalize="off" autocorrect="off" />    </div>
<div><label for="password">Password</label> <input id="password" type="password" name="password" value="" onKeyPress="capsLockOn(event);" />    </div>
<div><label for="ClockTime">&nbsp;</label><div id="ClockTime">Not Available</div></div>
<div class="buttons"><label for="submit">&nbsp;</label> <input class="colorSettings" type="submit" value="Submit" onClick="document.getElementById('buttonClicked').value='Submit';" /></div>
<input id="buttonClicked" type="hidden" name="buttonClicked" value="none"/>
</form>

并且使用以下代码,我至少能够预填用户名和密码字段:

$Url = “http://URL”
$Username=”user”
$Password=”pass”
$IE = New-Object -com internetexplorer.application;
$IE.visible = $true;
$IE.navigate($url);
while ($IE.Busy -eq $true)
{Start-Sleep -Milliseconds 2000;}
$IE.Document.getElementById(“username”).value = $Username
$IE.Document.getElementByID(“password”).value=$Password
$IE.Document.getElementById(“buttonClicked”).Click()

但是我无法点击提交按钮。

任何建设性的建议将不胜感激!

您可以将此作为最后一行并提交表单,而不是尝试单击按钮。

$IE.Document.getElementById("formMain").submit()