Ok, so I have written a pretty intense PowerShell script that installs and configures SharePoint 2007 and SQL 2008. That is what it is, please don't judge me. After finishing all of that up, because the script is supposed to be user friendly, I developed a web form to gather inputs and display task progress. Stupidly, I wrote all the code for the web form on Windows 8.1 without even testing the basic functions on Server 2008 R2 where the script will be executed. When I took the code over to the server, it malfunctioned pretty much immediately. When I then tested it on Windows 7, it worked fine.
Here is the behavior on Windows 8.1 (w/ IE 11) and Windows 7 (w/ 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
The list goes on for a while....
Now when I run the same code on 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
This is a little bit of a problem as the script pretty heavily relies on writing to and reading from the IE Document object and none of the classes I need are available. Rather no classes are available, even the ones I don't need.
So is there any way to access the document object on Server 2008 R2? I have gone through everything that I can think of with the security zone settings (although I may have missed something there), and I have disabled the enhanced security configuration and the IE protected mode. Nothing I have done seems to give me access to the document. Any advice?
Solved by deploying the Microsoft.mshtml.dll assembly from the Windows 8.1 machine to the GAC on the Server 2008 R2 machine using gacutil.exe and restarting the PowerShell instance.