Author Posts

January 27, 2016 at 2:24 am

Hi,

Made a script for login on splunk website and it is running successfully without any failure or error but not able to launch internet explorer so any insight will be appreciated.

$username = "username"
$password = "password"
$ie = New-Object -com InternetExplorer.Application
$ie.visible=$false
$ie.navigate("https://login.splunk.com/index.php?module=roles&func=showloginform")
while($ie.ReadyState -ne 4) {start-sleep -m 100}
$ie.document.getElementById("username").value= "$username"
$ie.document.getElementById("pass").value = "$password"
$ie.document.getElementById("loginform").submit()
start-sleep 20
$ie.Document.body | Out-File -FilePath c:\web.txt

Thanks
Ankit

January 27, 2016 at 4:14 am

IE will launch if you change $false to $true. Also, the page may need more time to load.

$username = "username"
$password = "password"
$ie = New-Object -com InternetExplorer.Application
$ie.visible=$True
$ie.navigate("https://login.splunk.com/index.php?module=roles&func=showloginform")
while($ie.ReadyState -ne 4) {start-sleep -Seconds 5}
$ie.document.getElementById("username").value= "$username"
$ie.document.getElementById("pass").value = "$password"
$ie.document.getElementById("loginform").submit()
start-sleep 5

January 27, 2016 at 4:25 am

thanks for the reply but when i am executing your given script by passing on username and password parameter it is showing "login error missing data- you must provide a username" (showing on splunk website) but i have already provided username and password in the script so do you have any idea for this?

Thanks in advance

January 27, 2016 at 5:59 am

I forgot you are using IE. The login element should have a click method used to click the login button. I don't have a Splunk account to test, but this should work. I recommend using Invoke-WebRequest or Invoke-RestMethod when sites are involved.

$username = "username"
$password = "password"
$ie = New-Object -com InternetExplorer.Application
$ie.visible=$True
$ie.navigate("https://login.splunk.com/index.php?module=roles&func=showloginform")
while($ie.ReadyState -ne 4) {start-sleep -Seconds 5}
$ie.document.getElementById("username").value= "$username"
$ie.document.getElementById("pass").value = "$password"
$ie.Document.getElementById('login').click()
start-sleep 5

January 27, 2016 at 6:20 am

Thanks a ton... its work.. 🙂