PowerShell Internet Explorer自动化错误服务器2012 [英] PowerShell internet explorer automation error server 2012

查看:82
本文介绍了PowerShell Internet Explorer自动化错误服务器2012的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PowerShell脚本,该脚本登录到我们的网站之一,单击一些链接然后关闭.基本上只是监视并确保一切正常!下面是脚本顶部的摘录.

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} 

基本上,此部分打开IE,然后单击继续"按钮以显示证书错误.如果我在Windows 7机器上运行此程序,则可以正常工作,但是在Server 2012 R2上,我会得到:

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:

您不能在空值表达式上调用方法"

台式机和服务器均运行PowerShell 4.0和Internet Explorer 11.

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

我读了一段时间,提到这可能是2012年的错误,它不允许此方法单击IE中的链接,但不记得在哪里以及是否有修复程序!

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?

我正在考虑的另一件事(如果有人可以麻烦解释!),我应该改用invoke-webrequest吗?如果可以,则可以登录到网站,打开一些链接(不必在屏幕上可见),然后关闭以确认所有链接都可以正常工作?

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!

推荐答案

只需启用Internet Explorer企业模式.

Just enable the Internet Explorer Enterprise Mode.

在Internet Explorer中,按"ALT"键,转到工具">企业模式".

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

如果企业模式不可用: •启动GPEDIT.MSC •转到用户配置">管理模板">"Windows组件">"Internet Explorer">使用户打开并使用工具"菜单中的企业模式" •已启用

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

它有效!

这篇关于PowerShell Internet Explorer自动化错误服务器2012的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆