diff --git a/CHANGELOG.md b/CHANGELOG.md index 994b0e4..c06e94f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,14 +44,17 @@ All notable changes to this project will be documented in this file. - Made bundled operating-system catalogs win when an external catalog has the same build revision, while preserving higher-revision external overlays. - Merged the OSD and OSDCloud catalog projections into `Get-OSDCoreOperatingSystems`, retaining each module's native property schema. - Updated deployment initialization, operating-system selection, default OS resolution, catalog refresh, maintenance guidance, and function help to use the unified provider and synchronized catalog model. +- Unified the shared private core utilities with OSD and renamed the centralized download helper to `Invoke-RecastOSDDownloadFile`. ### Fixed - Made HP driver pack catalog release-date parsing culture-independent. +- Corrected the shared download helper's forced WebClient path so it no longer overwrites the typed switch parameter. ### Removed - Removed the redundant private `Get-OSDCloudCoreOperatingSystems` provider after migrating its callers to the unified function. +- Removed the legacy `Invoke-OSDCloudDownloadFile` command name. ## 26.9.29.1 - September 29, 2026 diff --git a/OSDCloud/private/core-cache/Update-RecastOSDCloudUSBCache.ps1 b/OSDCloud/private/core-cache/Update-RecastOSDCloudUSBCache.ps1 index a6fd489..52b9ba5 100644 --- a/OSDCloud/private/core-cache/Update-RecastOSDCloudUSBCache.ps1 +++ b/OSDCloud/private/core-cache/Update-RecastOSDCloudUSBCache.ps1 @@ -325,7 +325,7 @@ function Update-RecastOSDCloudUSBCache { (New-Object System.Management.Automation.Host.ChoiceDescription '&No', 'Skip the OperatingSystem download.') ) if ($downloadOperatingSystem -and ($host.UI.PromptForChoice($caption, $message, $choices, 1) -eq 0)) { - $savedOperatingSystem = Invoke-OSDCoreDownloadFile -SourceUrl $selectedOperatingSystemUrl -DestinationDirectory $osdCoreOperatingSystemDestination -DestinationName $global:OSDCoreOperatingSystemCloudObject.FileName -ErrorAction Stop + $savedOperatingSystem = Invoke-RecastOSDDownloadFile -SourceUrl $selectedOperatingSystemUrl -DestinationDirectory $osdCoreOperatingSystemDestination -DestinationName $global:OSDCoreOperatingSystemCloudObject.FileName -ErrorAction Stop # Verify the downloaded payload before refreshing the cache inventory. if (-not [string]::IsNullOrWhiteSpace($expectedOperatingSystemHash)) { @@ -434,7 +434,7 @@ function Update-RecastOSDCloudUSBCache { (New-Object System.Management.Automation.Host.ChoiceDescription '&No', 'Skip the driver pack download.') ) if ($downloadDriverPack -and ($host.UI.PromptForChoice($caption, $message, $choices, 1) -eq 0)) { - $savedDriverPack = Invoke-OSDCoreDownloadFile -SourceUrl $global:OSDCoreDriverPackCloudObject.Url -DestinationDirectory $osdCoreDriverPackDestination -DestinationName $global:OSDCoreDriverPackCloudObject.FileName -ErrorAction Stop + $savedDriverPack = Invoke-RecastOSDDownloadFile -SourceUrl $global:OSDCoreDriverPackCloudObject.Url -DestinationDirectory $osdCoreDriverPackDestination -DestinationName $global:OSDCoreDriverPackCloudObject.FileName -ErrorAction Stop # Verify the downloaded driver pack before refreshing the cache inventory. if (-not [string]::IsNullOrWhiteSpace($expectedDriverPackHashMD5)) { diff --git a/OSDCloud/private/core/Get-DeploymentDiskObject.ps1 b/OSDCloud/private/core-disk/Get-DeploymentDiskObject.ps1 similarity index 100% rename from OSDCloud/private/core/Get-DeploymentDiskObject.ps1 rename to OSDCloud/private/core-disk/Get-DeploymentDiskObject.ps1 diff --git a/OSDCloud/private/core/Invoke-OSDCloudDownloadFile.ps1 b/OSDCloud/private/core/Invoke-RecastOSDDownloadFile.ps1 similarity index 85% rename from OSDCloud/private/core/Invoke-OSDCloudDownloadFile.ps1 rename to OSDCloud/private/core/Invoke-RecastOSDDownloadFile.ps1 index 1072632..0f5ce9d 100644 --- a/OSDCloud/private/core/Invoke-OSDCloudDownloadFile.ps1 +++ b/OSDCloud/private/core/Invoke-RecastOSDDownloadFile.ps1 @@ -1,12 +1,40 @@ -<# -.SYNOPSIS -Downloads a file from the internet and returns a Get-Item Object -.DESCRIPTION -Downloads a file from the internet and returns a Get-Item Object -.LINK -https://github.com/OSDeploy/OSD/tree/master/Docs -#> -function Invoke-OSDCloudDownloadFile { +function Invoke-RecastOSDDownloadFile { + <# + .SYNOPSIS + Downloads a file to a local path and returns file information. + + .DESCRIPTION + Downloads content from a source URL into a destination directory using + either curl or WebClient fallback logic, then returns a FileInfo object for + the downloaded file. + + .PARAMETER SourceUrl + Source URL to download. + + .PARAMETER DestinationName + Optional destination file name. If omitted, the file name is derived from + the source URL. + + .PARAMETER DestinationDirectory + Destination directory for the downloaded file. + + .PARAMETER Overwrite + Overwrites the destination file if it already exists. + + .PARAMETER WebClient + Forces use of WebClient instead of curl. + + .EXAMPLE + Invoke-RecastOSDDownloadFile -SourceUrl 'https://example.org/file.cab' -DestinationDirectory "$env:TEMP\OSD" + Downloads the file and returns a FileInfo object. + + .LINK + https://github.com/OSDeploy/OSD/tree/master/docs + + .NOTES + Author: David Segura - Recast Software + 2026-09-30 - Unified the OSD and OSDCloud download helpers + #> [CmdletBinding()] [OutputType([System.IO.FileInfo])] param @@ -33,6 +61,7 @@ function Invoke-OSDCloudDownloadFile { [System.Management.Automation.SwitchParameter] $WebClient ) + $Error.Clear() #================================================= # Values #================================================= @@ -108,9 +137,13 @@ function Invoke-OSDCloudDownloadFile { if ($UseWebClient -eq $true) { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls1 - $WebClient = New-Object System.Net.WebClient - $WebClient.DownloadFile($SourceUrl, $DestinationFullName) - $WebClient.Dispose() + $webClientInstance = New-Object System.Net.WebClient + try { + $webClientInstance.DownloadFile($SourceUrl, $DestinationFullName) + } + finally { + $webClientInstance.Dispose() + } } else { Write-Verbose "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] cURL Source: $SourceUrl" diff --git a/OSDCloud/private/steps/4-install/step-install-downloadwindowsimage.ps1 b/OSDCloud/private/steps/4-install/step-install-downloadwindowsimage.ps1 index fb3c084..de6434f 100644 --- a/OSDCloud/private/steps/4-install/step-install-downloadwindowsimage.ps1 +++ b/OSDCloud/private/steps/4-install/step-install-downloadwindowsimage.ps1 @@ -122,7 +122,7 @@ function step-install-downloadwindowsimage { $null = New-Item -Path $USBDownloadPath -ItemType Directory -Force } Write-Verbose -Message "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] Downloading Windows image to USB cache." - $SaveWebFile = Invoke-OSDCloudDownloadFile -SourceUrl $OperatingSystemFilePath -DestinationDirectory "$USBDownloadPath" -DestinationName $FileName + $SaveWebFile = Invoke-RecastOSDDownloadFile -SourceUrl $OperatingSystemFilePath -DestinationDirectory "$USBDownloadPath" -DestinationName $FileName if ($SaveWebFile) { Write-Verbose -Message "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] Copying cached Windows image from $($SaveWebFile.FullName) to $DownloadPath." @@ -135,7 +135,7 @@ function step-install-downloadwindowsimage { # $SaveWebFile is a FileInfo Object, not a path Write-Host -ForegroundColor DarkGray "[$(Get-Date -format s)] [INFO] DownloadPath: $DownloadPath" Write-Verbose -Message "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] Downloading Windows image directly to $DownloadPath." - $SaveWebFile = Invoke-OSDCloudDownloadFile -SourceUrl $OperatingSystemFilePath -DestinationDirectory $DownloadPath -ErrorAction Stop + $SaveWebFile = Invoke-RecastOSDDownloadFile -SourceUrl $OperatingSystemFilePath -DestinationDirectory $DownloadPath -ErrorAction Stop $FileInfo = $SaveWebFile } #================================================= diff --git a/OSDCloud/private/steps/5-drivers/step-Save-WindowsDriver-DriverPack.ps1 b/OSDCloud/private/steps/5-drivers/step-Save-WindowsDriver-DriverPack.ps1 index 96aa726..afe2809 100644 --- a/OSDCloud/private/steps/5-drivers/step-Save-WindowsDriver-DriverPack.ps1 +++ b/OSDCloud/private/steps/5-drivers/step-Save-WindowsDriver-DriverPack.ps1 @@ -203,7 +203,7 @@ function step-Save-WindowsDriver-DriverPack { } Write-Verbose -Message "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] Downloading DriverPack to USB cache." Write-Host -ForegroundColor DarkGray "[$(Get-Date -format s)] [PROGRESS] Downloading or reusing the driver pack in the USB cache." - $SaveWebFile = Invoke-OSDCloudDownloadFile -SourceUrl $DriverPackCloudObject.Url -DestinationDirectory $USBDownloadPath -DestinationName $FileName -ErrorAction Stop + $SaveWebFile = Invoke-RecastOSDDownloadFile -SourceUrl $DriverPackCloudObject.Url -DestinationDirectory $USBDownloadPath -DestinationName $FileName -ErrorAction Stop if ($SaveWebFile) { Write-Verbose -Message "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] Copying cached DriverPack from $($SaveWebFile.FullName) to $DownloadPath." Write-Host -ForegroundColor DarkGray "[$(Get-Date -format s)] [PROGRESS] Copying cached driver pack from:" @@ -223,7 +223,7 @@ function step-Save-WindowsDriver-DriverPack { $ProgressPhase = "Downloading driver pack to $DownloadPath" Write-Host -ForegroundColor DarkGray "[$(Get-Date -format s)] [PROGRESS] USB cache did not provide a usable file. Downloading directly to:" Write-Host -ForegroundColor DarkGray " $DownloadPath" - $SaveWebFile = Invoke-OSDCloudDownloadFile -SourceUrl $DriverPackCloudObject.Url -DestinationDirectory $DownloadPath -DestinationName $FileName -ErrorAction Stop + $SaveWebFile = Invoke-RecastOSDDownloadFile -SourceUrl $DriverPackCloudObject.Url -DestinationDirectory $DownloadPath -DestinationName $FileName -ErrorAction Stop $FileInfo = $SaveWebFile } } @@ -235,7 +235,7 @@ function step-Save-WindowsDriver-DriverPack { Write-Host -ForegroundColor DarkGray "[$(Get-Date -format s)] [PROGRESS] Downloading driver pack directly to:" Write-Host -ForegroundColor DarkGray " $DownloadPath" Write-Verbose -Message "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] Downloading DriverPack directly to $DownloadPath." - $SaveWebFile = Invoke-OSDCloudDownloadFile -SourceUrl $DriverPackCloudObject.Url -DestinationDirectory $DownloadPath -ErrorAction Stop + $SaveWebFile = Invoke-RecastOSDDownloadFile -SourceUrl $DriverPackCloudObject.Url -DestinationDirectory $DownloadPath -ErrorAction Stop $FileInfo = $SaveWebFile } #=================================================