Public/Functions/split/Save-EnablementPackage.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 |
function Save-EnablementPackage { [CmdletBinding()] param ( [Parameter(ValueFromPipeline = $true)] [Alias ('DownloadFolder','Path')] [string]$DownloadPath = "$env:TEMP", [ValidateSet('22H2','21H2','21H1','20H2','1909')] [Alias('Build')] [string]$OSBuild = '21H1', [ValidateSet('x64','x86')] [string]$OSArch = 'x64' ) #================================================= # Get-EnablementPackage #================================================= $Result = Get-EnablementPackage -OSBuild $OSBuild -OSArch $OSArch #================================================= # SaveWebFile #================================================= if ($Result) { if (Test-Path "$DownloadPath\$($Result.FileName)") { Get-Item "$DownloadPath\$($Result.FileName)" } elseif (Test-WebConnection -Uri "$($Result.FileUri)") { $SaveWebFile = Save-WebFile -SourceUrl $Result.FileUri -DestinationDirectory "$DownloadPath" -DestinationName $Result.FileName if (Test-Path $SaveWebFile.FullName) { Get-Item $SaveWebFile.FullName } else { Write-Warning "Could not download the Enablement Package" } } else { Write-Warning "Could not verify an Internet connection for the Enablement Package" } } else { Write-Warning "Unable to determine a suitable Enablement Package" } } |