将凭据插入Windows登录弹出窗口

时间:2014-03-31 12:28:53

标签: powershell login credentials

我一直在尝试创建一个脚本,将一些凭据自动插入到标准Windows登录屏幕中的报告服务器中。

到目前为止:

$ie = new-Object -com internetexplorer.application;
$ie.visible = $true;
$ie.navigate($url);
while ($ie.Busy -eq $true)
{
    start-sleep -milliseconds 1000;
}
$ie.Document.getElementById(“user_email”).value = $username
$ie.Document.getElementByID(“user_password”).value=$password
$ie.Document.getElementById(“commit”).Click();
$ie.fullscreen = $true;
$cmd.Quit();

当使用普通网站(浏览器在网站本身的网站)时,此脚本可以正常工作

但是在加载网站之前提示进行身份验证时,我需要更改它以便能够插入我的凭据吗? (Windows安全窗口)

1 个答案:

答案 0 :(得分:2)

找到解决方案,它并不漂亮,但它确实有效:

$wshell = New-Object -com WScript.Shell
$wshell.Run("iexplore.exe $url")
Start-Sleep 1

$wshell.sendkeys("$username")
$wshell.sendkeys("{TAB}")
$wshell.sendkeys("$password")
$wshell.sendkeys("{TAB}")
$wshell.sendkeys("{ENTER}")

如果我找到更好的解决方案,我会确保发布,或者随时发布您自己的解决方案:P