Public/Get-IEVersion.ps1

Function Get-IEVersion {
    <#
        .Synopsis
            Get-IEVersion helps collecting IE version information
 
        .Description
            Written with the ever growing need for information in mind Get-IEVersion can collect information about installed Internet Explorer versions
 
        .Parameter ComputerName
            Provide an array of computernames to query (default is localhost)
 
        .Example
            Get-IEVersion -ComputerName "Computer01"
 
            Status ComputerName Version
            ------ ------------ -------
            Connected COMPUTER01 9.11.17134.0
 
            Shows Internet Explorer version for Computer01
 
        .LINK
            about_functions_advanced
 
        .LINK
            about_CommonParameters
    #>

    [CmdletBinding()]
    [OutputType('JBOAPPLS.IE.Version.Information')]
    Param (
        [Parameter(
            ValueFromPipeline = $True,
            ValueFromPipelineByPropertyName = $True,
            HelpMessage = 'Provide computernames'
        )]
        [Alias('cn', 'Identity', 'Hostname', 'Server')]
        [string[]]$ComputerName = "localhost"
    )
    Begin {
        Write-Debug "PsBoundParameters:"
        $PSBoundParameters.GetEnumerator() | ForEach-Object { Write-Debug $_ }
        If ($PSBoundParameters['Debug']) {
            $DebugPreference = 'Continue'
        }
        Write-Debug "$($MyInvocation.MyCommand.Name):: DebugPreference: $DebugPreference"

        Write-Verbose "$($MyInvocation.MyCommand.Name):: Function started"

        $IEkeyname = 'SOFTWARE\\Microsoft\\Internet Explorer'

    }
    Process {
        ForEach ($Computer In $ComputerName) {
            Write-Verbose ('{0}:: Retrieving data from {1}' -f $MyInvocation.MyCommand, $Computer)
            Try {
                $Computer = $Computer.ToUpper()
                If ($Computer -eq $env:COMPUTERNAME -or $Computer -eq "localhost") {
                    $reg = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine', 'Registry64')
                } Else {
                    $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computer)
                }
                $IEkey = $reg.OpenSubkey($IEkeyname)
                $IEvalue = $IEkey.GetValue('Version')

                $properties = @{
                    PSTypeName   = 'JBOAPPLS.IE.Version.Information'
                    ComputerName = $Computer
                    Version      = $IEvalue
                    Status       = 'Connected'
                }

            } Catch {
                $properties = @{
                    PSTypeName   = 'JBOAPPLS.IE.Version.Information'
                    ComputerName = $Computer
                    Version      = $null
                    Status       = 'Disconnected'
                }

            } Finally {

                $array = New-Object -TypeName PSObject -Property $properties
                Write-Output $array
            }
        }
    }
    End {
        Write-Verbose "$($MyInvocation.MyCommand.Name):: Function ended"
    }

}
Set-Alias -Name Show-IEVersion -Value Get-IEVersion -Description "Get IE Version" -ErrorAction SilentlyContinue