Get-Browser.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function Get-Browser
{
    <#
    .Synopsis
        Gets open browsers
    .Description
        Gets browsers that have already been opened
    .Example
        Get-Browser
    .Link
        Open-Browser
    #>

    param(
    [Switch]
    $Bodyhtml
    )
     
    process {
        (New-Object -ComObject Shell.Application).Windows() | 
            Where-Object { 
                $_.Fullname -and $_.Fullname -like "*iexplore.exe"
            } |
            ForEach-Object {
                if ($Bodyhtml) {
                    $_.Document.body.innerHtml
                } else {
                    $_
                }
            }
    }
}