Powershell SSL证书警告中断IE自动化
我需要在CUCM(Cisco Unified Communications Manager)上自动执行一些操作,因此我正在使用PowerShell的Powershell SSL证书警告中断IE自动化,powershell,internet-explorer,ssl,Powershell,Internet Explorer,Ssl,我需要在CUCM(Cisco Unified Communications Manager)上自动执行一些操作,因此我正在使用PowerShell的InternetExplorer.Application 但是,我发现了一个与SSL错误相关的问题: 接下来,我首先找到转到网页链接并发送一个点击操作-这非常有效 但是,当下一个页面加载时(我需要输入登录详细信息),我的脚本无法使用 在此对象上找不到属性“value”。验证该属性是否存在,并且是否可以 准备好了。 在C:\temp\termTEST
InternetExplorer.Application
但是,我发现了一个与SSL错误相关的问题:
接下来,我首先找到转到网页链接并发送一个点击操作-这非常有效
但是,当下一个页面加载时(我需要输入登录详细信息),我的脚本无法使用
在此对象上找不到属性“value”。验证该属性是否存在,并且是否可以
准备好了。
在C:\temp\termTEST\TermForm.ps1:34字符:2
+$document.getelementsbyname(“j_用户名”)[0]。值='sebastian.k。。。
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo:InvalidOperation:(:)[],运行时异常
+FullyQualifiedErrorId:PropertyAsignmentException
但是我可以确认登录字段存在,因此$ie
或$document
对象似乎被回收或类似的东西,这意味着我无法访问这些字段
我怎样才能克服这个问题
剧本:
$ie = New-Object -ComObject internetexplorer.application
$ie.navigate("https://10.40.193.31/ccmadmin/phoneFindList.do")
$ie.visible = $true
while ($ie.busy) { sleep 1 }
$global:document = $ie.document
#A while loop to check for IE certificate errors on the page and continue loading the page anyway if there are any
while ($document.readyState -ne 'complete') { sleep -Milliseconds 100 }
if ($document.getelementbyID("overridelink"))
{
$document.getelementbyid("overridelink").click();
while ($ie.busy) { sleep 1 }
$document;
while ($document.readyState -ne 'complete') { sleep -Milliseconds 100 }
}
#Loading the credentials from the queryCredentials function to log onto the portal
$document.getelementsbyname("j_username")[0].value = 'Bassie' # ERROR OCCURS HERE
$document.getelementsbyname("j_password")[0].value = 'password'
$document.getelementbyid("logonform").submit()
如果我手动单步执行代码并实际单击continue链接(导致If
语句跳过),则登录字段填充得很好,因此这肯定与证书错误消息有关
我尝试将证书安装到我的机器上,但由于某种原因,我仍然收到了消息。还联系了我们的支持团队以更新证书,但他们拒绝帮助我,因此我只能依靠自己。以下是一些事实: