首页 > 解决方案 > $ie.document 方法对于 powershell 中的控制台页面不可见

问题描述

我正在使用 powershell 自动登录页面,但是当我导航到登录控制台页面时,没有 $ie.document 方法可见。并显示空错误。控制台页面存在的方法是:

CreateObjRef 等于
GetHashCode
GetLifetimeService
GetType
InitializeLifetimeService
ToString

我使用的代码是:-

$ie = New-Object -ComObject 'internetExplorer.Application'
$ie.Visible= $true # Make it visible
While ($ie.Busy -eq $true) {Start-Sleep -Seconds 7;}
$ie.Navigate("https://matlktwlsapp001:16311/ibm/console/")
start-sleep -s 2;
$ie | gm;
$qw = $ie.document.getElementById("overridelink");
$qw.click();

错误:- 您不能在空值表达式上调用方法。

At line:7 char:1
+ $qw = $ie.document.getElementById("overridelink");
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:8 char:1
+ $qw.click();
+ ~~~~~~~~~~~
+ CategoryInfo          : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

请帮助!

标签: powershellpowershell-2.0domdocumentgetelementbyidcomobject

解决方案


推荐阅读