refreshing web page using powershell

痞子三分冷 提交于 2021-01-28 19:39:07

问题


I need to refresh only the current web page using powershell.But all the opened web pages are being refreshed.My code is here

   function Refresh-WebPages {
        param(
            $interval = 5
        )
        "Refreshing IE Windows every $interval seconds."
        "Press any key to stop."
        $shell = New-Object -ComObject Shell.Application
        do {
            'Refreshing ALL HTML'
            $shell.Windows() | 
                Where-Object { $_.Document.url } | 
                ForEach-Object { $_.Refresh() }
            Start-Sleep -Seconds $interval
        } until ( [System.Console]::KeyAvailable )
        [System.Console]::ReadKey($true) | Out-Null
    }

回答1:


You have the Where clause which filters out all windows with .url

Where-Object { $_.Document.url }

All you would need to do is refine that for the specific url you are looking for.

Where-Object { $_.Document.url -like 'http://google*' } 

That would filter out all the pages that start with http://google. If there is a more elegant solution for targeting one page I am not aware of it.



来源:https://stackoverflow.com/questions/25888915/refreshing-web-page-using-powershell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!