Frage

I've been trying to create a script that would insert some credentials automatically into the standard windows login screen to a reports server.

what i have so far:

$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();

this script works fine when using normal websites (ones where browser is in the website itself)

but what do I need to change it to be able to insert my credentials when prompted for auth before loading the website? (the windows security window)

War es hilfreich?

Lösung

Found solution, it's not pretty, but it works:

$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}")

if I find a better solution, I'll make sure to post it, or feel free to post your own :P

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top