powershell - 如何使用Powershell关闭现有IE窗口中的选项卡

标签 powershell

您好有谁知道如何使用powershell在Internet Explorer中打开和关闭选项卡。我可以使用以下方法打开一个

 $navOpenInNewTab = 0x800
 # Get running Internet Explorer instances
 $oApp = New-Object -ComObject shell.application
 # Grab the last opened tab
 $oIE = $oApp.Windows() | Select-Object -Last 1
 # Open link in the new tab nearby
 $oIE_Total_Sends = $oIE.navigate($link, $navOpenInNewTab) 
 while ($oIE.busy) {
 sleep -milliseconds 50
 }

我如何通过Powershell关闭此新选项卡,为什么不能访问getElementByID对象上的Internet Explorer方法(如$oIE.Document)。

最佳答案

这是一个将关闭IE中选项卡的功能。

Function Close-IETab {
param($url)

    $oWindows = (New-Object -ComObject Shell.Application).Windows

    foreach ($oWindow in $oWindows.Invoke()) {

        if ($oWindow.Fullname -match "IEXPLORE.EXE" -and $oWindow.LocationURL -match $url) {

            Write-verbose "Closing tab $($oWindow.LocationURL)"
            $oWindow.Quit()
        }
    }

}

关于powershell - 如何使用Powershell关闭现有IE窗口中的选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49575365/

相关文章:

powershell - Azure 资源管理器 - 如何更改资源的资源组?

powershell - 连接-AzureRmAccount : accessing_ws_metadata_exchange_failed

postgresql - 连接到 Postgresql 数据库并执行 SQL 命令时调用 Sqlcmd 失败

azure - 使用 Azure CLI 设置 Azure Function 应用程序配置时出现 ) 问题

powershell - 使用 powershell 自动化部署 Azure WebJob

powershell - 导出 Active Directory 中用户的所有属性和值

powershell - Powershell-从循环中提取到CSV

file - 如何根据行值拆分CSV文件

c# - 如何使用 Cake 安装 Bower 软件包 (http ://cakebuild.net)

powershell - 在 Powershell 中使用的月 DD、YYYY 的正确日期格式字符串是什么