private/WinPEDrivers/CloudWinPEDriver/Get-CloudWinPEDriverIntelWifi.ps1
|
#Requires -PSEdition Core function Get-CloudWinPEDriverIntelWifi { <# .SYNOPSIS Discovers the latest Intel PROSet/Wireless IT Administrators driver pack metadata. .DESCRIPTION Internal helper called by Update-OSDeployWinPEDriversCatalog. Fetches the Intel Download Center page stored in config.json, extracts the current IT Administrators Wi-Fi 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-wifi'.UpdateUri if ([string]::IsNullOrWhiteSpace($searchUri)) { throw "intel-wifi 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 download page '$searchUri'" $response = Invoke-WebRequest -Uri $searchUri -Headers $requestHeaders -UseBasicParsing -ErrorAction Stop $html = $response.Content # Find the direct IT Administrators zip download URL in page source. $downloadUriMatch = [regex]::Match( $html, '(?i)(https://downloadmirror\.intel\.com/(?<Id>\d{6,7})/(?<FileName>WiFi-(?<Version>\d+\.\d+\.\d+)-Driver64-Win10-Win11\.zip))' ) if (-not $downloadUriMatch.Success) { Write-Warning "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] Could not find Intel wireless 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 $readmeUri = "https://downloadmirror.intel.com/$mirrorId/ReleaseNotes_WiFi_${version}_IT.pdf" Write-Verbose "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] Found DownloadUri='$downloadUri'" # Extract SHA256 — usually shown next to the zip filename on the page $sha256Match = [regex]::Match($html, '(?i)sha256[:\s]+([A-Fa-f0-9]{64})') $sha256 = $sha256Match.Groups[1].Value.Trim() # Extract file size in MB $fileSizeMB = $null $sizeMatch = [regex]::Match($html, '(?i)(\d+(?:\.\d+)?)\s*MB') if ($sizeMatch.Success) { $fileSizeMB = [double]$sizeMatch.Groups[1].Value } # Extract release date from page metadata first, then fall back to visible text. $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 (-not $dateMatch.Success) { $dateMatch = [regex]::Match($html, '(?i)(?:date|released)[:\s]+(\d{1,2}/\d{1,2}/\d{4}|[A-Za-z]+\s+\d{1,2},\s+\d{4})') } if ($dateMatch.Success) { $releaseDateValue = if ($dateMatch.Groups['Date'].Success) { $dateMatch.Groups['Date'].Value } else { $dateMatch.Groups[1].Value } $releaseDate = & $convertReleaseDate $releaseDateValue } $checksums = @{} if ($sha256) { $checksums['SHA256'] = $sha256 } Write-Verbose "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] PackageId='$mirrorId' Version='$version' ReleaseDate='$releaseDate'" @( [PSCustomObject]@{ Architecture = 'amd64' ReadmeUri = $readmeUri PackageId = $mirrorId Version = $version ReleaseDate = $releaseDate FileName = $fileName FileSizeMB = $fileSizeMB DownloadUri = $downloadUri Checksums = [PSCustomObject]$checksums } ) } catch { Write-Warning "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] $($_.Exception.Message)" } } |