Public/Get-Zoom.ps1

Function Get-Zoom {    
    <#
        .SYNOPSIS
            Get the current version and download URL for Zoom.

        .NOTES
            Author: Trond Eirik Haavarstein
            Twitter: @xenappblog
        
        .LINK
            https://github.com/aaronparker/Evergreen

        .EXAMPLE
            Get-Zoom

            Description:
            Returns the current version and download URL for Zoom.
    #>

    [OutputType([System.Management.Automation.PSObject])]
    [CmdletBinding()]
    Param()

    # Get application resource strings from its manifest
    $res = Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1]
    Write-Verbose -Message $res.Name

    If (Test-PSCore) {
        Write-Warning -Message "This function is currently unsupported on PowerShell Core. Please use Windows PowerShell."
    }
    Else {
        #region Zoom for Windows clients and plug-ins
        ForEach ($installer in $res.Get.WindowsUris.GetEnumerator()) {

            # Request the download URL to grab the header that includes the URL to the download
            # Handling HTTP 302 on PowerShell Core fails
            try {
                $iwrParams = @{
                    Uri                = $res.Get.WindowsUris[$installer.Key]
                    UserAgent          = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome
                    MaximumRedirection = 0
                    UseBasicParsing    = $True
                    ErrorAction        = "SilentlyContinue"
                }
                $request = Invoke-WebRequest @iwrParams
            }
            catch [System.Net.WebException] {
                Write-Warning -Message ([string]::Format("Error : {0}", $_.Exception.Message))
            }
            catch [System.Exception] {
                Write-Warning -Message "$($MyInvocation.MyCommand): failed to invoke request to: $Uri."
                Throw $_.Exception.Message
            }
            finally {
                # Match version number from the download URL
                If ($request.Headers.Location -match $res.Get.MatchVersion) {
                    $Version = $Matches[0]
                }
                Else {
                    $Version = "Unknown"
                }

                If ($request.StatusCode -ge 300 -and $request.StatusCode -lt 400) {
                    $PSObject = [PSCustomObject] @{
                        Version  = $Version
                        Platform = "Windows"
                        Type     = $installer.Name
                        URI      = $request.Headers.Location
                    }
                    Write-Output -InputObject $PSObject
                }
            }
        }
        #endregion

        #region Zoom for Virtual Desktops (Citrix)
        ForEach ($installer in $res.Get.CitrixVDIUris.GetEnumerator()) {

            # Request the download URL to grab the header that includes the URL to the download
            # Handling HTTP 302 on PowerShell Core fails
            try {
                $iwrParams = @{
                    Uri                = $res.Get.CitrixVDIUris[$installer.Key]
                    UserAgent          = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome
                    MaximumRedirection = 0
                    UseBasicParsing    = $True
                    ErrorAction        = "SilentlyContinue"
                }
                $request = Invoke-WebRequest @iwrParams
            }
            catch [System.Net.WebException] {
                Write-Warning -Message ([string]::Format("Error : {0}", $_.Exception.Message))
            }
            catch [System.Exception] {
                Write-Warning -Message "$($MyInvocation.MyCommand): failed to invoke request to: $Uri."
                Throw $_.Exception.Message
            }
            finally {
                # Match version number from the download URL
                If ($request.Headers.Location -match $res.Get.MatchVersion) {
                    $Version = $Matches[0]
                }
                Else {
                    $Version = "Unknown"
                }

                If ($request.StatusCode -ge 300 -and $request.StatusCode -lt 400) {
                    $PSObject = [PSCustomObject] @{
                        Version  = $Version
                        Platform = "Citrix"
                        Type     = $installer.Name
                        URI      = $request.Headers.Location
                    }
                    Write-Output -InputObject $PSObject
                }
            }
        }
        #endregion

        #region Zoom for Virtual Desktops (VMware)
        ForEach ($installer in $res.Get.VMwareVDIUris.GetEnumerator()) {

            # Request the download URL to grab the header that includes the URL to the download
            # Handling HTTP 302 on PowerShell Core fails
            try {
                $iwrParams = @{
                    Uri                = $res.Get.VMwareVDIUris[$installer.Key]
                    UserAgent          = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome
                    MaximumRedirection = 0
                    UseBasicParsing    = $True
                    ErrorAction        = "SilentlyContinue"
                }
                $request = Invoke-WebRequest @iwrParams
            }
            catch [System.Net.WebException] {
                Write-Warning -Message ([string]::Format("Error : {0}", $_.Exception.Message))
            }
            catch [System.Exception] {
                Write-Warning -Message "$($MyInvocation.MyCommand): failed to invoke request to: $Uri."
                Throw $_.Exception.Message
            }
            finally {
                # Match version number from the download URL
                If ($request.Headers.Location -match $res.Get.MatchVersion) {
                    $Version = $Matches[0]
                }
                Else {
                    $Version = "Unknown"
                }

                If ($request.StatusCode -ge 300 -and $request.StatusCode -lt 400) {
                    $PSObject = [PSCustomObject] @{
                        Version  = $Version
                        Platform = "VMware"
                        Type     = $installer.Name
                        URI      = $request.Headers.Location
                    }
                    Write-Output -InputObject $PSObject
                }
            }
        }
        #endregion
    }
}