forked from aaronparker/evergreen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-Zoom.ps1
58 lines (52 loc) · 2.1 KB
/
Get-Zoom.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Function Get-Zoom {
<#
.SYNOPSIS
Get the current version and download URL for Zoom.
.NOTES
Author: Trond Eirik Haavarstein
Twitter: @xenappblog
#>
[OutputType([System.Management.Automation.PSObject])]
[CmdletBinding(SupportsShouldProcess = $False)]
param (
[Parameter(Mandatory = $False, Position = 0)]
[ValidateNotNull()]
[System.Management.Automation.PSObject]
$res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1])
)
ForEach ($platform in $res.Get.Download.Keys) {
ForEach ($installer in $res.Get.Download[$platform].Keys) {
# Follow the download link which will return a 301/302
$redirectUrl = Resolve-SystemNetWebRequest -Uri $res.Get.Download[$platform][$installer]
# Match the URL without the text after the ?
If ($Null -eq $redirectUrl) {
Write-Verbose -Message "$($MyInvocation.MyCommand): Setting fallback URL to: $($script:resourceStrings.Uri.Issues)."
$Url = $script:resourceStrings.Uri.Issues
}
Else {
try {
$Url = [RegEx]::Match($redirectUrl.ResponseUri.AbsoluteUri, $res.Get.MatchUrl).Captures.Groups[1].Value
}
catch {
$Url = $redirectUrl.ResponseUri.AbsoluteUri
}
}
# Match version number from the download URL
try {
$Version = [RegEx]::Match($Url, $res.Get.MatchVersion).Captures.Groups[0].Value
}
catch {
$Version = "Latest"
}
# Construct the output; Return the custom object to the pipeline
$PSObject = [PSCustomObject] @{
Version = $Version
Platform = $platform
Type = Get-FileType -File $Url
Architecture = Get-Architecture -String $Url
URI = $Url
}
Write-Output -InputObject $PSObject
}
}
}