@@ -67,6 +67,7 @@ if ($Host.Version.Major -eq 5)
6767}
6868
6969[xml ]$Config = Get-Content - Path " $PSScriptRoot \Default.xml" - Encoding Default - Force
70+ $DownloadsFolder = Get-ItemPropertyValue - Path " HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" - Name " {374DE290-123F-4565-9164-39C4925E467B}"
7071
7172switch ($Branch )
7273{
@@ -164,27 +165,42 @@ foreach ($Component in $Components)
164165 Write-Information - MessageData " " - InformationAction Continue
165166 Write-Verbose - Message " OneDrive Downloading" - Verbose
166167
167- # Parse XML to get the URL
168- # https://go.microsoft.com/fwlink/p/?LinkID=844652
169- $Parameters = @ {
170- Uri = " https://g.live.com/1rewlive5skydrive/OneDriveProductionV2"
171- UseBasicParsing = $true
172- Verbose = $true
168+ try
169+ {
170+ # Parse XML to get the URL
171+ # https://go.microsoft.com/fwlink/p/?LinkID=844652
172+ $Parameters = @ {
173+ Uri = " https://g.live.com/1rewlive5skydrive/OneDriveProductionV2"
174+ UseBasicParsing = $true
175+ Verbose = $true
176+ }
177+ $Content = Invoke-RestMethod @Parameters
178+ }
179+ catch [System.Net.WebException ]
180+ {
181+ Write-Verbose - Message " Connection could not be established with https://oneclient.sfx.ms" - Verbose
182+ exit
173183 }
174- $Content = Invoke-RestMethod @Parameters
175184
176185 # Remove invalid chars
177186 [xml ]$OneDriveXML = $Content -replace " " , " "
178-
179187 $OneDriveURL = ($OneDriveXML ).root.update.amd64binary.url | Select-Object - Index 1
180- $DownloadsFolder = Get-ItemPropertyValue - Path " HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" - Name " {374DE290-123F-4565-9164-39C4925E467B}"
181- $Parameters = @ {
182- Uri = $OneDriveURL
183- OutFile = " $DownloadsFolder \OneDriveSetup.exe"
184- UseBasicParsing = $true
185- Verbose = $true
188+
189+ try
190+ {
191+ $Parameters = @ {
192+ Uri = $OneDriveURL
193+ OutFile = " $DownloadsFolder \OneDriveSetup.exe"
194+ UseBasicParsing = $true
195+ Verbose = $true
196+ }
197+ Invoke-WebRequest @Parameters
198+ }
199+ catch [System.Net.WebException ]
200+ {
201+ Write-Verbose - Message " Connection could not be established with https://oneclient.sfx.ms" - Verbose
202+ exit
186203 }
187- Invoke-WebRequest @Parameters
188204
189205 Start-Process - FilePath " $DownloadsFolder \OneDriveSetup.exe" - Wait
190206 Remove-Item - Path " $DownloadsFolder \OneDriveSetup.exe" - Force
@@ -208,7 +224,7 @@ foreach ($Component in $Components)
208224 $Node = $Config.SelectSingleNode (" //ExcludeApp[@ID='PowerPoint']" )
209225 $Node.ParentNode.RemoveChild ($Node )
210226 }
211- OneNote
227+ OneNote
212228 {
213229 $Node = $Config.SelectSingleNode (" //ExcludeApp[@ID='OneNote']" )
214230 $Node.ParentNode.RemoveChild ($Node )
@@ -223,15 +239,22 @@ foreach ($Component in $Components)
223239 Write-Information - MessageData " " - InformationAction Continue
224240 Write-Verbose - Message " Teams Downloading" - Verbose
225241
226- # https://www.microsoft.com/microsoft-teams/download-app
227- $DownloadsFolder = Get-ItemPropertyValue - Path " HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" - Name " {374DE290-123F-4565-9164-39C4925E467B}"
228- $Parameters = @ {
229- Uri = " https://statics.teams.cdn.office.net/evergreen-assets/DesktopClient/MSTeamsSetup.exe"
230- OutFile = " $DownloadsFolder \MSTeams-x64.msix"
231- UseBasicParsing = $true
232- Verbose = $true
242+ try
243+ {
244+ # https://www.microsoft.com/microsoft-teams/download-app
245+ $Parameters = @ {
246+ Uri = " https://statics.teams.cdn.office.net/evergreen-assets/DesktopClient/MSTeamsSetup.exe"
247+ OutFile = " $DownloadsFolder \MSTeams-x64.msix"
248+ UseBasicParsing = $true
249+ Verbose = $true
250+ }
251+ Invoke-RestMethod @Parameters
252+ }
253+ catch [System.Net.WebException ]
254+ {
255+ Write-Verbose - Message " Connection could not be established with https://statics.teams.cdn.office.net" - Verbose
256+ exit
233257 }
234- Invoke-RestMethod @Parameters
235258 }
236259 ProjectPro2019Volume
237260 {
@@ -273,24 +296,32 @@ if (((Get-WinHomeLocation).GeoId -eq "203") -or ((Get-WinHomeLocation).GeoId -eq
273296}
274297
275298# It is needed to remove these keys to bypass Russian and Belarusian region blocks
276- Remove-Item - Path HKCU:\SOFTWARE\Microsoft\Office\16.0 \Common\Experiment - Recurse - Force - ErrorAction Ignore
277- Remove-Item - Path HKCU:\SOFTWARE\Microsoft\Office\16.0 \Common\ExperimentConfigs - Recurse - Force - ErrorAction Ignore
278- Remove-Item - Path HKCU:\SOFTWARE\Microsoft\Office\16.0 \Common\ExperimentEcs - Recurse - Force - ErrorAction Ignore
299+ $Paths = @ (
300+ " HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Experiment" ,
301+ " HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\ExperimentConfigs" ,
302+ " HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\ExperimentEcs"
303+ )
304+ Remove-Item - Path $Paths - Recurse - Force - ErrorAction Ignore
279305
280306# Download Office Deployment Tool
281307# https://www.microsoft.com/en-us/download/details.aspx?id=49117
282308if (-not (Test-Path - Path " $PSScriptRoot \setup.exe" ))
283309{
284- $Parameters = @ {
285- Uri = " https://officecdn.microsoft.com/pr/wsus/setup.exe"
286- OutFile = " $PSScriptRoot \setup.exe"
287- UseBasicParsing = $true
288- Verbose = $true
310+ try
311+ {
312+ $Parameters = @ {
313+ Uri = " https://officecdn.microsoft.com/pr/wsus/setup.exe"
314+ OutFile = " $PSScriptRoot \setup.exe"
315+ UseBasicParsing = $true
316+ Verbose = $true
317+ }
318+ Invoke-WebRequest @Parameters
319+ }
320+ catch [System.Net.WebException ]
321+ {
322+ Write-Verbose - Message " Connection could not be established with https://officecdn.microsoft.com" - Verbose
323+ exit
289324 }
290- Invoke-WebRequest @Parameters
291-
292- # Expand officedeploymenttool.exe
293- # Start-Process "$PSScriptRoot\officedeploymenttool.exe" -ArgumentList "/quiet /extract:`"$PSScriptRoot\officedeploymenttool`"" -Wait
294325}
295326
296327# Start downloading to the Office folder
0 commit comments