0

I have a PowerShell script that logs into one of our sites, clicks some links then closes. Basically just to monitor and make sure everything works ok! below is a snippet from the top of the script.

$ie = new-object -com "InternetExplorer.Application"
$ie.visible = $true
$ie.navigate($url)
while( $ie.busy){Start-Sleep 1} 
$doc = $ie.document
$continue = $doc.getElementByID("overridelink")
$continue.click()
while( $ie.busy){Start-Sleep 1} 

Basically this section opens IE and clicks continue button for certificate error. If i run this on my windows 7 machine it works fine, however on Server 2012 R2 i get:

"You cannot call a method on a null-valued expression"

Both desktop and server are running PowerShell 4.0 and Internet explorer 11.

I read something a while back that mentioned this may be a bug in 2012 where it doesn't allow this method to click links in IE but cant remember where and if there was a fix!

Does anyone know what causes this and maybe how to resolve it?

another thing i was thinking(if anyone can be bothered to explain!), should i be using invoke-webrequest instead? if so is it possible to log into a site, open some links(doesn't have to be visible on screen) then close confirming it all works?

Thanks in advance for any input!

1 Answer 1

1

Just enable the Internet Explorer Enterprise Mode.

In Internet Explorer, Press "ALT" key, go to Tools > Enterprise Mode.

If Enterprise Mode is not available: •Launch GPEDIT.MSC •Go to User Configuration > Administrative Templates > Windows Components > Internet Explorer > Let users turn on and use Enterprise Mode from the Tools menu •enabled

and it work !

Sign up to request clarification or add additional context in comments.

2 Comments

I've tried disabling enhanced security, adding site to trusted sites, adding site to compatibility view list. But this is what finally did the trick. Thank you!
Additionally, since I was navigating through the site, I had to set Enterprise mode for each page I touched.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.