# ── Feature metadata ────────────────────────────────────────────────────────── $FeatureMeta = @{ Name = 'DefaultBrowser' Description = 'Notify when the default browser does not match the configured app' Settings = @( @{ Key = 'targetProgId' Label = 'Target ProgId' Type = 'string' Default = 'OperaGXStable' Description = 'ProgId of the desired default browser (e.g. OperaGXStable, ChromeHTML, FirefoxURL-308046B0AF4A39CB)' } ) } # ── Feature implementation ──────────────────────────────────────────────────── function Invoke-Feature { param( [hashtable]$Config, [hashtable]$State ) if (-not $State) { $State = @{} } if (-not $State.ContainsKey('lastShownDate')) { $State['lastShownDate'] = $null } $today = (Get-Date).ToString('yyyy-MM-dd') # Only notify once per day if ($State['lastShownDate'] -eq $today) { Write-Log -Level Info -Message 'Already checked today, skipping.' -Feature 'DefaultBrowser' return $State } $regPath = 'HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice' try { $currentProgId = (Get-ItemProperty -Path $regPath -Name 'ProgId' -ErrorAction Stop).ProgId } catch { Write-Log -Level Warn ` -Message "Could not read current default browser ProgId from registry: $_" ` -Feature 'DefaultBrowser' return $State } if ($currentProgId -eq $Config['targetProgId']) { Write-Log -Level Info ` -Message "Default browser OK: '$currentProgId'." ` -Feature 'DefaultBrowser' $State['lastShownDate'] = $today return $State } Write-Log -Level Warn ` -Message "Default browser mismatch — found '$currentProgId', expected '$($Config['targetProgId'])'." ` -Feature 'DefaultBrowser' # Note: Windows 11 blocks programmatic default-browser changes via registry hash protection. # We guide the user to the Settings page instead. Show-ToastNotification ` -Title 'Default Browser' ` -Body ("Default browser is '$currentProgId'. Click below to set it to $($Config['targetProgId']).") ` -Buttons @( @{ Label = 'Open Default Apps Settings'; Action = 'ms-settings:defaultapps' }, @{ Label = 'Dismiss'; Action = 'dismiss' } ) $State['lastShownDate'] = $today return $State }