forked from aaronparker/evergreen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-Zoom.ps1
85 lines (73 loc) · 3.54 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
function Get-Zoom {
<#
.SYNOPSIS
Get the current version and download URL for Zoom.
.NOTES
Author: Aaron Parker
Twitter: @stealthpuppy
#>
[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])
)
# Get the download data from the API
$params = @{
Uri = $res.Get.Download.Uri
ContentType = $res.Get.Download.ContentType
}
$DownloadFeed = Invoke-RestMethodWrapper @params
# Step through each the download types
foreach ($Property in $res.Get.Download.Properties) {
# Construct the URL for the User installer
$Url = "$($res.Get.Download.Hostname)/$($DownloadFeed.result.downloadVO.$Property.version)/$($DownloadFeed.result.downloadVO.$Property.packageName)"
# Add the architecture to the URL
if (-not([System.String]::IsNullOrEmpty($DownloadFeed.result.downloadVO.$Property.archType))) {
$Url = "$Url$("?archType=")$($DownloadFeed.result.downloadVO.$Property.archType)"
}
# Resolve the download URL
$ResolvedUrl = Resolve-SystemNetWebRequest -Uri $Url
# Version number
if ($DownloadFeed.result.downloadVO.$Property.version -eq "latest") {
$Version = $DownloadFeed.result.downloadVO.$Property.displayVersion -replace "\s+\(", "." -replace "\)", ""
}
else {
$Version = $DownloadFeed.result.downloadVO.$Property.version
}
# Create an output object
$Output = [PSCustomObject]@{
Version = $Version
Platform = $res.Get.Download.PropertyMatrix[$Property]
Installer = "User"
Size = $ResolvedUrl.ContentLength
Type = Get-FileType -File $ResolvedUrl.ResponseUri.AbsoluteUri
Architecture = Get-Architecture -String $ResolvedUrl.ResponseUri.AbsoluteUri
URI = $ResolvedUrl.ResponseUri.AbsoluteUri
}
Write-Output -InputObject $Output
# Construct the URL for the IT installer
if (-not([System.String]::IsNullOrEmpty($DownloadFeed.result.downloadVO.$Property.packageNameForIT))) {
$Url = "$($res.Get.Download.Hostname)/$($DownloadFeed.result.downloadVO.$Property.version)/$($DownloadFeed.result.downloadVO.$Property.packageNameForIT)"
# Add the architecture to the URL
if (-not([System.String]::IsNullOrEmpty($DownloadFeed.result.downloadVO.$Property.archType))) {
$Url = "$Url$("?archType=")$($DownloadFeed.result.downloadVO.$Property.archType)"
}
# Resolve the download URL
$ResolvedUrl = Resolve-SystemNetWebRequest -Uri $Url
# Create an output object
$Output = [PSCustomObject]@{
Version = $Version
Platform = $res.Get.Download.PropertyMatrix[$Property]
Installer = "Admin"
Size = $ResolvedUrl.ContentLength
Type = Get-FileType -File $ResolvedUrl.ResponseUri.AbsoluteUri
Architecture = Get-Architecture -String $ResolvedUrl.ResponseUri.AbsoluteUri
URI = $ResolvedUrl.ResponseUri.AbsoluteUri
}
Write-Output -InputObject $Output
}
}
}