我的脚本中有这个非常简单的片段:
$ie = New-Object -ComObject InternetExplorer.Application
$ie.visible = $true
$ie.navigate("https://10.0.0.1/ccmadmin/phoneFindList.do")
while ($ie.readyState -ne 4) { Start-Sleep -Milliseconds 100; Write-Host $ie.readyState }
我之前肯定使用过非常相似的代码而没有任何问题,但是由于某种原因,当我运行此脚本时,$ie.readyState
只包含一个空值,因此将一个空字符串输出到控制台,它永远不会得到设置为4
(或其他任何事情。
我可以看到该页面有一个证书错误,但我很确定它仍然有效。
什么可能导致这个问题?
当单步执行脚本时,我可以看到readyState
包含值0一直到第3行,我们调用navigate
- 此时readyState
已设置空字符串或空白...
答案 0 :(得分:0)
当您查看有关MSDN和W3C网站上的基础IHTMLXMLHttp *信息的所有API信息时,没有迹象表明正在使用SSL限制。对请求进行跟踪并查看它正在挂起的属性。
READYSTATE_UNINITIALIZED (0)
The object has been created, but not initialized (the IHTMLXMLHttpRequest::open method has not been called).
READYSTATE_LOADING (1)
A request has been opened, but the IHTMLXMLHttpRequest::send method has not been called.
READYSTATE_LOADED (2)
The IHTMLXMLHttpRequest::send method has been called. No data is available yet.
READYSTATE_INTERACTIVE (3)
Some data has been received; however, IHTMLXMLHttpRequest::responseText is not available.
READYSTATE_COMPLETE (4)
All the data has been received.