diff --git a/Install-MicrosoftOffice365.ps1 b/Install-MicrosoftOffice365.ps1 index 056720f..6c82795 100644 --- a/Install-MicrosoftOffice365.ps1 +++ b/Install-MicrosoftOffice365.ps1 @@ -52,6 +52,15 @@ function Get-OfficeDeploymentDefinitions { MinimumServerBuild = 20348 MinimumServerRevision = 2402 Windows11Build = 22000 + # Windows 10 stays on this feature release; resolve its latest published build + # per channel at run time rather than maintaining a fixed patch/build number. + Windows10OfficeRelease = '2608' + OfficeReleaseHistory = 'https://learn.microsoft.com/en-us/officeupdates/update-history-microsoft365-apps-by-date' + OfficeReleaseHistoryChannels = @{ + Current = 'current-channel' + MonthlyEnterprise = 'monthly-enterprise-channel' + SemiAnnual = 'semi-annual-enterprise-channel' + } TeamsUnsupportedWindows10Editions = @('EnterpriseS', 'EnterpriseSN', 'IoTEnterpriseS') # Teams.exe is classic, msteams.exe is the older personal/Windows Chat client, # and ms-teams.exe is the current client. Check all three before removal. @@ -103,6 +112,8 @@ function Get-OfficeDeploymentOptions { $company = $company.Trim() if ($company -eq 'None') { $company = '' } $options = @{ OfficeSubscription = $subscription; ProductId = $plans[$subscription]; Company = $company; ValidateBeforeChanges = $validateOnly; DeferReboot = $deferReboot } + # Internal values, populated from the host and Microsoft's release history, not RMM input. + $options.OfficeFeatureRelease = ''; $options.TargetOfficeVersion = '' # Derive this from the validated product mapping, including standalone Apps plans and legacy aliases. $options.InstallTeams = $options.ProductId -in $definitions.TeamsProducts foreach ($name in $choices.Keys) { @@ -131,6 +142,33 @@ function Assert-OfficeDeploymentHost { $os = Get-CimInstance Win32_OperatingSystem -ErrorAction Stop $windows = Get-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -ErrorAction Stop Assert-OfficeCompanionPlatform -Build ([int]$os.BuildNumber) -ProductType ([int]$os.ProductType) -Revision ([int]$windows.UBR) -EditionId $windows.EditionID -InstallTeams $Options.InstallTeams + $Options.OfficeFeatureRelease = Get-OfficeFeatureRelease -Build ([int]$os.BuildNumber) -ProductType ([int]$os.ProductType) + $null = Write-Output "Deployment host: $($os.Caption), build $($os.BuildNumber).$($windows.UBR)." +} + +function Get-OfficeFeatureRelease { + param([int]$Build, [int]$ProductType) + $definitions = Get-OfficeDeploymentDefinitions + if ($ProductType -eq 1 -and $Build -ge $definitions.MinimumWindowsBuild -and $Build -lt $definitions.Windows11Build) { return $definitions.Windows10OfficeRelease } + return '' +} + +function Get-OfficeBuildFromHistory { + param([string]$PageContent, [string]$UpdateChannel, [string]$FeatureRelease) + $definitions = Get-OfficeDeploymentDefinitions + $article = $definitions.OfficeReleaseHistoryChannels[$UpdateChannel] + if (!$article -or $FeatureRelease -notmatch '^\d{4}$') { throw 'Invalid Office release-history selection.' } + $linkPattern = '(^|/)' + [regex]::Escape($article) + '#version-' + $FeatureRelease + '(?:-|$)' + $labelPattern = '^\s*Version\s+' + $FeatureRelease + '\s+\(Build\s+(?\d+\.\d+)\)\s*$' + $content = [Net.WebUtility]::HtmlDecode($PageContent) + $builds = @(foreach ($link in [regex]::Matches($content, ']*\bhref\s*=\s*["''](?[^"'']+)["''][^>]*>(?