I had a similar issue compared to the following SO threads:
Powershell System.__ComObject.document property no longer works under IE 9
PowerShell IE9 ComObject has all null properties after navigating to webpage
Cannot find an overload for "getElementById" and the argument count: "1"
My error was something to the effect of:
Cannot find an overload for "getElementsByName" and the argument count: "1"...
So I looked at each of these threads to help determine the why and the solutions to this problem.
I'm running PowerShell 4.0
on Windows Server 2012 R2
. The script runs with Execution Policy Bypass
and I am also running PowerShell as an Administrator (i..e. Administrator: Windows PowerShell ISE) AND my user account is part of the Administrator group. The URL the script is accessing is on the Intranet
(one would think Internet Explorer
isolates it to the proper zone, namely the Intranet Zone
).
The script worked fine on my local machine but not on this server.
Here are the list of things I tried--one at at time, never in combination--that failed to yield a successful outcome:
- Disabled Protected Mode in the Internet Zone.
- Added URL to Trusted Zone Sites. Note that Protected Mode was already disabled. Only change I made here was adding the URL to the Trusted Sites list.
- Disabled IE Enhanced Security Configuration completely. Administrators was already set to Off, but Users was set to On. I set Users to Off, which had no effect.
- Ensured PowerShell ISE was running in Administrator mode (elevated privileges). It didn't seem to matter what mode PowerShell ISE was running in, likely because Execution Policy is set to Bypass.
- Added URL to Intranet Zone Site List. Note that Protected Mode was set to disabled, prior to. Only change I made in this zone was adding the URL to its Site List. Initially worked but then I tried again and same problem. May have been a fluke that it worked.
Here are the list of things that I tried--again, one at a time--that solved the problem:
- Added URL to Compatibility View with Display intranet sites in Compatibility View unchecked.
- Added URL to Compatibility View with Display intranet sites in Compatibility View checked.
So the question is why does employing Compatibility View resolve the problem? What's different about this that the other things I tried didn't work?
One would think Trusted Zone Site List should do the trick. Security Level for Trusted Zone is set to Medium. For Intranet Zone, it's Medium-low. And for Internet Zone, it's set to Custom.
Is it related to one or more of the individual properties that you can set in a Security Level? Is it something under the covers with Registry, COM, IE?
Good thing is I found 2 solutions which worked. Bad thing is I don't quite understand why. Obviously, it works because of some relaxed security permissions. Maybe it's also tied to Group Policy settings. I'm not sure.
Anyone have any ideas here? Thank you.