好的,所以我编写了一个非常强大的 PowerShell 脚本来安装和配置 SharePoint 2007 和 SQL 2008。就是这样,请不要评判我。在完成所有这些之后,因为脚本应该是用户友好的,所以我开发了一个 Web 表单来收集输入并显示任务进度。愚蠢的是,我在 Windows 8.1 上编写了 Web 表单的所有代码,甚至没有在将执行脚本的 Server 2008 R2 上测试基本功能。当我将代码交给服务器时,它几乎立即出现故障。然后,当我在 Windows 7 上对其进行测试时,它运行良好。
以下是 Windows 8.1(带 IE 11)和 Windows 7(带 IE 9)上的行为:
>$ie = New-Object -ComObject InternetExplorer.Application
>$ie.Navigate('about:blank')
>$ie.visible = $true #Internet explorer is now displayed with a blank page
>$ie.document
Script : System.__ComObject
all : System.__ComObject
body : System.__ComObject
activeElement : System.__ComObject
images : System.__ComObject
applets : System.__ComObject
links : System.__ComObject
forms : System.__ComObject
anchors : System.__ComObject
title :
scripts : System.__ComObject
designMode : Inherit
selection : System.__ComObject
readyState : complete
名单持续了一段时间......
现在,当我在 Server 2008 R2 上运行相同的代码时:
>$ie = New-Object -ComObject InternetExplorer.Application
>$ie.Navigate('about:blank')
>$ie.visible = $true #Internet explorer is now displayed with a blank page
>$ie.document
System.__ComObject
这是一个小问题,因为脚本在很大程度上依赖于写入和读取 IE Document 对象,而且我需要的类都不可用。而是没有可用的课程,即使是我不需要的课程。
那么有什么方法可以访问 Server 2008 R2 上的文档对象呢?我已经通过安全区域设置完成了我能想到的所有事情(尽管我可能在那里遗漏了一些东西),并且我禁用了增强的安全配置和 IE 保护模式。我所做的一切似乎都无法让我访问该文档。有什么建议吗?