简体   繁体   English

Windows Server 2008 R2 PowerShell和Internet Explorer 9

[英]Windows Server 2008 R2 PowerShell and Internet Explorer 9

This is a Powershell script that runs just fine under Server 2003. We're needing to move to Server 2008 R2 and the script isn't working. 这是一个Powershell脚本,可以在Server 2003下正常运行。我们需要移至Server 2008 R2,该脚本无法正常工作。 Specifically the script is not sleeping while waiting for IE to finish loading the page. 特别是,脚本在等待IE完成加载页面时没有处于休眠状态。

$objIE = New-Object -ComObject "InternetExplorer.Application"
if($objIE.ReadyState -notmatch "0|1|2|3|4")
{
    $objIE = [System.Runtime.InteropServices.Marshal]::GetActiveObject("InternetExplorer.Application")
    if($objIE.ReadyState -notmatch "0|1|2|3|4")
    {
        Stop-Process -processname iexplore
        $objIE = New-Object -ComObject "InternetExplorer.Application"
    }
}

$objIE.Visible = $giShowResults

$objIE.Navigate($gsURL + "APAdmin.asp?cmd=login&loginname=" + $gsAdminName + "&password=" >>+ $gsAdminPassword)
while($objIE.Busy -eq $true)
{                        
    $dtNow = Get-Date
    Start-Sleep 1 # Sleep for one second
}
$objIE.Navigate($gsURL + "APAdmProcessClosings.asp?cmd=run&AutomatedProcess=y")
while($objIE.Busy -eq $true)
{
    Start-Sleep 1 # Sleep for one second
}

When I run with Visible set to true I can see IE open, the APAdmin.asp page loads, and then the script says it's finished without running the APAdmProcessClosings.asp page. 当我在Visible设置为true的情况下运行时,我可以看到IE已打开,APAdmin.asp页已加载,然后脚本说它已完成,无需运行APAdmProcessClosings.asp页。

I've searched the Net but haven't been able to find any reason why yet. 我已经在网上搜索过,但还没有找到任何原因。

It appears the Enhanced Security Configuration was the problem. 看来增强安全配置是问题所在。 Once I added the site to the list of trusted sites then the job would run successfully. 将站点添加到受信任站点列表后,该作业将成功运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM