I have the script below that I am running on a 2008R2 server with Powershell 3 installed. I am trying to use the script to log in to one of our web servers and write the logged in pass fail to host.
It does not log into the site and I believe it is because the log in page has not finished loading when it tries to log in.
I there any way to break it up and add sleep time to let the pages load before entering id an pw and writing pass fail to host? Also is there any way to make IE viewable while this is processing?
$r = Invoke-WebRequest $url -Method Post -Body $formFields -ContentType "application/x-www-form-urlencoded"
#sleep -seconds 15
$r | out-file "C:\monitorFolder\httpcopy.html"
if ($r.Content -match $contains)
Write-Host "Success($deviceName)=The web page contains the string '$contains'.";
Write-Host "Failure($deviceName)=The web page does not contain the string '$contains'.";