private/Get-OSDeployCatalogMetadata.ps1
|
#Requires -PSEdition Core #Requires -Version 7.4 function Get-OSDeployCatalogMetadata { <# .SYNOPSIS Gets metadata from an OSDeploy operating system catalog name .DESCRIPTION Parses a catalog filename in the format <major>.<ubr>.<yyMMdd>-<HHmm>.xml, validates its release timestamp, and maps the build major to the corresponding Windows release folder. Only Windows 11 25H2 build major 26200 is supported. .PARAMETER Name Specifies the catalog filename to parse, including the .xml extension. .EXAMPLE PS> Get-OSDeployCatalogMetadata -Name '26200.9457.260913-0221.xml' Returns the catalog identity, parsed build and release timestamp, and the Windows 11 25H2 folder name. .INPUTS None. This function does not accept pipeline input. .OUTPUTS System.Management.Automation.PSCustomObject. Returns the catalog identity, build, build major, release timestamp, and Windows release folder name. .NOTES Author: David Segura Company: Recast Software Version: 1.0.0 Date: 2026-09-24 #> [CmdletBinding()] [OutputType([System.Management.Automation.PSCustomObject])] param ( [Parameter(Mandatory)] [System.String] $Name ) $nameMatch = [regex]::Match( $Name, '^(?<Identity>(?<Major>\d{5})\.(?<Ubr>0|[1-9]\d*)\.(?<Timestamp>\d{6}-\d{4}))\.xml$', [System.Text.RegularExpressions.RegexOptions]::CultureInvariant ) if (-not $nameMatch.Success) { throw [System.FormatException]::new( "Catalog name '$Name' does not use the expected '<major>.<ubr>.<yyMMdd>-<HHmm>.xml' format." ) } try { $releaseDateTime = [datetime]::ParseExact( $nameMatch.Groups['Timestamp'].Value, 'yyMMdd-HHmm', [System.Globalization.CultureInfo]::InvariantCulture, [System.Globalization.DateTimeStyles]::None ) } catch { throw [System.FormatException]::new( "Catalog name '$Name' contains an invalid release timestamp.", $_.Exception ) } $buildMajor = [int]$nameMatch.Groups['Major'].Value $osFolderName = switch ($buildMajor) { 26200 { 'Windows 11 25H2' } default { throw [System.NotSupportedException]::new( "Catalog name '$Name' contains unsupported build major $buildMajor." ) } } [pscustomobject]@{ Identity = $nameMatch.Groups['Identity'].Value Build = [version]("$($nameMatch.Groups['Major'].Value).$($nameMatch.Groups['Ubr'].Value)") BuildMajor = $buildMajor ReleaseDateTime = $releaseDateTime OSFolderName = $osFolderName } } |