private/WinPEDrivers/CloudWinPEDriver/Get-CloudWinPEDriverIntelEthernet.ps1
|
#Requires -PSEdition Core function Get-CloudWinPEDriverIntelEthernet { <# .SYNOPSIS Discovers the latest Intel Ethernet driver pack metadata. .DESCRIPTION Internal helper called by Update-OSDeployWinPEDriversCatalog. Fetches the Intel download page stored in config.json, extracts the current x64 Ethernet driver package metadata directly from the page, and returns a single-element array. No extra metadata fetches, downloads, or extraction are performed. .OUTPUTS [PSCustomObject[]] One entry: Architecture, ReadmeUri, Id, Version, ReleaseDate, FileName, FileSizeMB, DownloadUri, Checksums. #> [CmdletBinding()] [OutputType([PSCustomObject[]])] param () try { $searchUri = $global:OSDeployModule.WinPEDrivers.'intel-ethernet'.UpdateUri if ([string]::IsNullOrWhiteSpace($searchUri)) { throw "intel-ethernet UpdateUri is not defined in winpedrivers.json." } $convertReleaseDate = { param([string]$Value) foreach ($format in @('M/d/yyyy', 'MM/dd/yyyy', 'MMMM d, yyyy', 'MMM d, yyyy', 'yyyy-MM-dd')) { try { return [datetime]::ParseExact( $Value, $format, [System.Globalization.CultureInfo]::InvariantCulture ).ToString('yyyy-MM-dd') } catch { } } try { ([datetime]$Value).ToString('yyyy-MM-dd') } catch { $Value } } $requestHeaders = [ordered]@{ 'User-Agent' = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36' 'Accept' = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' 'Accept-Language' = 'en-US,en;q=0.9' 'Accept-Encoding' = 'gzip, deflate, br, zstd' 'Cache-Control' = 'max-age=0' 'Upgrade-Insecure-Requests' = '1' 'Sec-Fetch-Site' = 'none' 'Sec-Fetch-Mode' = 'navigate' 'Sec-Fetch-User' = '?1' 'Sec-Fetch-Dest' = 'document' 'sec-ch-ua' = '"Chromium";v="135", "Google Chrome";v="135", "Not.A/Brand";v="8"' 'sec-ch-ua-mobile' = '?0' 'sec-ch-ua-platform' = '"Windows"' } Write-Verbose "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] Fetching Intel Ethernet download page '$searchUri'" $response = Invoke-WebRequest -Uri $searchUri -Headers $requestHeaders -UseBasicParsing -ErrorAction Stop $html = $response.Content $downloadUriMatch = [regex]::Match( $html, '(?i)(https://downloadmirror\.intel\.com/(?<Id>\d{6,7})/(?<FileName>Release_(?<Version>[\d\.]+)\.zip))' ) if (-not $downloadUriMatch.Success) { Write-Warning "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] Could not find Intel Ethernet zip download URL on page '$searchUri'. Page format may have changed." return } $downloadUri = $downloadUriMatch.Groups[1].Value $mirrorId = $downloadUriMatch.Groups['Id'].Value $fileName = $downloadUriMatch.Groups['FileName'].Value $version = $downloadUriMatch.Groups['Version'].Value $readmeMatch = [regex]::Match( $html, '(?i)(https://downloadmirror\.intel\.com/' + [regex]::Escape($mirrorId) + '/readme\.txt)' ) $readmeUri = if ($readmeMatch.Success) { $readmeMatch.Groups[1].Value } else { $searchUri } $sha256Match = [regex]::Match($html, '(?i)SHA256[:\s]+([A-Fa-f0-9]{64})') $sha256 = $sha256Match.Groups[1].Value.Trim() $fileSizeMB = $null $sizeMatch = [regex]::Match($html, '(?i)Size:\s*(\d+(?:\.\d+)?)\s*MB') if ($sizeMatch.Success) { $fileSizeMB = [double]$sizeMatch.Groups[1].Value } $releaseDate = $null $dateMatch = [regex]::Match( $html, '(?i)<meta[^>]+name="(?:lastModifieddate|LastUpdate)"[^>]+content="(?<Date>\d{1,2}/\d{1,2}/\d{4})(?:\s+\d{2}:\d{2}:\d{2})?"' ) if ($dateMatch.Success) { $releaseDate = & $convertReleaseDate $dateMatch.Groups['Date'].Value } $checksums = @{} if ($sha256) { $checksums['SHA256'] = $sha256 } Write-Verbose "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] PackageId='$mirrorId' Version='$version' ReleaseDate='$releaseDate'" @( [PSCustomObject]@{ PackageId = $mirrorId Architecture = 'amd64' ReadmeUri = $readmeUri ReleaseDate = $releaseDate Version = $version FileName = $fileName FileSizeMB = $fileSizeMB DownloadUri = $downloadUri Checksums = [PSCustomObject]$checksums } ) } catch { Write-Warning "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] $($_.Exception.Message)" } } |