-
Notifications
You must be signed in to change notification settings - Fork 31
/
Get-MicrosoftTeams.ps1
254 lines (238 loc) · 9.4 KB
/
Get-MicrosoftTeams.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
param (
[Parameter(Mandatory = $true)]
[ValidateSet("dev", "prod", "life", "gcc", "gcchigh", "dod", "gallatin", IgnoreCase = $false)]
[string]$Environment,
[Parameter(Mandatory = $true)]
[ValidateSet("ring0", "ring0_s", "ring1", "ring1_5", "ring1_6", "ring2", "ring3", "ring3_6", "ring3_9", "general", "general_gcc", IgnoreCase = $false)]
[string]$Ring,
[Parameter(Mandatory = $true)]
[ValidateSet("win-x64", "win-x86", "win-arm64", "osx-x64 + osx-arm64", IgnoreCase = $false)]
[string]$Platform,
[Parameter(Mandatory = $true)]
[ValidateSet("Desktop", "Rooms", "Xbox", IgnoreCase = $false)]
[string]$Client,
[Parameter(Mandatory = $true)]
[ValidateSet("1.0", "2.0", "2.1", IgnoreCase = $false)]
[string]$Version,
[Parameter(Mandatory = $false)]
[ValidateSet("exe", "msi", "msix", IgnoreCase = $false)]
[string]$Type,
[Parameter(Mandatory = $false)]
[ArgumentCompletions("3a7cf1d3-06fa-4ead-bf45-a6286ff2620a")]
[string]$ObjectId,
[Parameter(Mandatory = $false)]
[ArgumentCompletions("72f988bf-86f1-41af-91ab-2d7cd011db47")]
[string]$TenantId
)
$ErrorActionPreference = "SilentlyContinue"
$ProgressPreference = "SilentlyContinue"
$ObjectId = $ObjectId.ToLower()
$TenantId = $TenantId.ToLower()
#
if ($Environment -eq "dev" -or $Environment -eq "prod" -or $Environment -eq "life" -or $Environment -eq "gcc") {
$ecsUrl = "https://config.teams.microsoft.com"
}
if ($Environment -eq "gcchigh") {
$ecsUrl = "https://config.ecs.gov.teams.microsoft.us"
}
if ($Environment -eq "dod") {
$ecsUrl = "https://config.ecs.dod.teams.microsoft.us"
}
if ($Environment -eq "gallatin") {
$ecsUrl = "https://mooncake.config.teams.microsoft.com"
}
#
if ($Ring -eq "ring0" -or $Ring -eq "ring0_s" -or $Ring -eq "ring1") {
$staticsUrl = "https://staticsint.teams.cdn.office.net"
if ($Client -eq "Xbox") {
$staticsUrl = "https://statics.teams.cdn.office.net"
if ($Ring -eq "ring0_s") {
$Ring = "ring0"
}
}
}
if ($Ring -eq "ring1_5" -or $Ring -eq "ring1_6" -or $Ring -eq "ring2" -or $Ring -eq "ring3" -or $Ring -eq "ring3_6" -or $Ring -eq "ring3_9" -or $Ring -eq "general" -or $Ring -eq "general_gcc") {
$staticsUrl = "https://statics.teams.cdn.office.net"
}
#
if ($Version -eq "1.0") {
if ($Client -eq "Desktop") {
$platformId = "27"
if ($Platform -eq "win-x64") {
if ($Type -eq "exe") {
$filePath = "production-windows-x64"
$fileName = "Teams_windows_x64.exe"
}
if ($Type -eq "msi") {
$filePath = "production-windows-x64"
$fileName = "Teams_windows_x64.msi"
}
if ($Type -eq "msix") {
$filePath = "production-windows-msix-x64"
$fileName = "Teams_windows_x64.msix"
}
}
if ($Platform -eq "win-x86") {
if ($Type -eq "exe") {
$filePath = "production-windows"
$fileName = "Teams_windows.exe"
}
if ($Type -eq "msi") {
$filePath = "production-windows"
$fileName = "Teams_windows.msi"
}
if ($Type -eq "msix") {
$filePath = "production-windows-msix"
$fileName = "Teams_windows.msix"
}
}
if ($Platform -eq "win-arm64") {
if ($Type -eq "exe") {
$filePath = "production-windows-arm64"
$fileName = "Teams_windows_arm64.exe"
}
if ($Type -eq "msi") {
$filePath = "production-windows-arm64"
$fileName = "Teams_windows_arm64.msi"
}
if ($Type -eq "msix") {
$filePath = "production-windows-msix-arm64"
$fileName = "Teams_windows_arm64.msix"
}
}
if ($Platform -eq "osx-x64 + osx-arm64") {
$platformId = "28"
$filePath = "production-osx"
$fileName = "Teams_osx.pkg"
}
}
}
if ($Version -eq "2.0") {
$platformId = "48"
if ($Client -eq "Desktop") {
if ($Platform -eq "win-x64") {
$filePath = "production-windows-x64"
$fileName = "MicrosoftTeams-x64.msix"
}
if ($Platform -eq "win-x86") {
$filePath = "production-windows-x86"
$fileName = "MicrosoftTeams-x86.msix"
}
if ($Platform -eq "win-arm64") {
$filePath = "production-windows-arm64"
$fileName = "MicrosoftTeams-arm64.msix"
}
}
if ($Client -eq "Xbox") {
if ($Platform -eq "win-x64") {
$filePath = "production-windows-xbox-x64"
$fileName = "MSTeamsPlayTogether_x64.msixbundle"
}
if ($Platform -eq "win-x86") {
$filePath = "production-windows-xbox-x86"
$fileName = "MSTeamsPlayTogether_x86.msixbundle"
}
}
}
if ($Version -eq "2.1") {
if ($Client -eq "Desktop") {
$platformId = "49"
if ($Platform -eq "win-x64") {
$filePath = "production-windows-x64"
$fileName = "MSTeams-x64.msix"
}
if ($Platform -eq "win-x86") {
$filePath = "production-windows-x86"
$fileName = "MSTeams-x86.msix"
}
if ($Platform -eq "win-arm64") {
$filePath = "production-windows-arm64"
$fileName = "MSTeams-arm64.msix"
}
if ($Platform -eq "osx-x64 + osx-arm64") {
$platformId = "50"
$filePath = "production-osx"
$fileName = "MicrosoftTeams.pkg"
}
}
if ($Client -eq "Rooms") {
$platformId = "51"
if ($Platform -eq "win-x64") {
$filePath = "production-windows-x64"
$fileName = "MSTeams-Rooms-x64.msix"
}
if ($Platform -eq "win-x86") {
$filePath = "production-windows-x86"
$fileName = "MSTeams-Rooms-x86.msix"
}
if ($Platform -eq "win-arm64") {
$filePath = "production-windows-arm64"
$fileName = "MSTeams-Rooms-arm64.msix"
}
}
}
#
$maxAttempts = 0
while ($maxAttempts -le 32) {
try {
if ($ObjectId -and $TenantId) {
$TeamsBuilds = (Invoke-RestMethod -Uri "$ecsUrl/config/v1/MicrosoftTeams/$($platformId)_1.0.0.0?environment=$($Environment)&audienceGroup=$($Ring)&teamsRing=$($Ring)&id=$($ObjectId)&tenantId=$($TenantId)&agent=TeamsBuilds" -Method Get).BuildSettings
}
else {
$TeamsBuilds = (Invoke-RestMethod -Uri "$ecsUrl/config/v1/MicrosoftTeams/$($platformId)_1.0.0.0?environment=$($Environment)&audienceGroup=$($Ring)&teamsRing=$($Ring)&agent=TeamsBuilds" -Method Get).BuildSettings
}
if ($Version -eq "1.0") {
if ($Client -eq "Desktop") {
if ($Platform -eq "win-x64" -or $Platform -eq "win-x86" -or $Platform -eq "win-arm64") {
$buildVersion = $TeamsBuilds.Desktop.windows64.latestVersion
}
if ($Platform -eq "osx-x64 + osx-arm64") {
$buildVersion = $TeamsBuilds.Desktop.osx.latestVersion
}
}
}
if ($Version -eq "2.0") {
if ($Client -eq "Desktop") {
if ($Platform -eq "win-x64" -or $Platform -eq "win-x86" -or $Platform -eq "win-arm64") {
$buildVersion = $TeamsBuilds.WebView2.x64.latestVersion
}
}
if ($Client -eq "Xbox") {
if ($Platform -eq "win-x64" -or $Platform -eq "win-x86") {
$buildVersion = $TeamsBuilds.GamebarWidget.x64.latestVersion
}
}
}
if ($Version -eq "2.1") {
if ($Client -eq "Desktop") {
if ($Platform -eq "win-x64" -or $Platform -eq "win-x86" -or $Platform -eq "win-arm64") {
$buildVersion = $TeamsBuilds.WebView2Canary.x64.latestVersion
}
if ($Platform -eq "osx-x64 + osx-arm64") {
$buildVersion = $TeamsBuilds.WebView2Canary.macOS.latestVersion
}
}
if ($Client -eq "Rooms") {
if ($Platform -eq "win-x64" -or $Platform -eq "win-x86" -or $Platform -eq "win-arm64") {
$buildVersion = $TeamsBuilds.WebView2Canary.MTRW.x64.latestVersion
if ($null -eq $buildVersion) {
$buildVersion = $TeamsBuilds.WebView2Canary.x64.latestVersion
}
}
}
}
if ($buildVersion) {
$fileUrl = (Invoke-WebRequest -Uri "$staticsUrl/$filePath/$buildVersion/$fileName" -Method Head)
$fileLastModified = [string]$fileUrl.Headers["Last-Modified"]
$convertDateToPST = [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId((Get-Date -Date $fileLastModified), "Pacific Standard Time")
$formatDate = (Get-Date -Date $convertDateToPST -Format "dddd, MMMM d, yyyy") + " at " + (Get-Date -Date $convertDateToPST -Format "h:mm tt")
$convertFileSizeToMB = [string]$fileUrl.Headers["Content-Length"] / 1024 / 1024
$roundFileSize = [System.Math]::Round($convertFileSizeToMB)
Write-Output " $buildVersion ($Platform) - published on $formatDate with $roundFileSize MB: $staticsUrl/$filePath/$buildVersion/$fileName"
}
break
}
catch {
$maxAttempts++
}
}