Add new features: DefaultBrowser, DynamicLock, SandwichReminder

- Implemented DefaultBrowser feature to notify users when the default browser does not match the configured app.
- Added DynamicLock feature to disable Dynamic Lock while connected to a specific network and re-enable it after disconnecting.
- Created SandwichReminder feature to prompt users to order a sandwich during work hours based on network and time settings.

Introduced helper libraries for configuration, elevation, logging, network utilities, and toast notifications.

- Config.ps1: Added functions for reading and writing configuration and state files.
- Elevation.ps1: Added functions to check for administrator privileges and request elevation.
- Logging.ps1: Implemented a shared logging utility for consistent logging across features.
- NetworkUtils.ps1: Added a function to check for DNS suffix connectivity.
- ToastHelper.ps1: Created a helper for displaying Windows toast notifications.

Implemented runner.ps1 as the main entry point for executing features based on configuration.
This commit is contained in:
Arne Moerman
2026-05-08 11:48:39 +02:00
commit 34ea1eb4b2
12 changed files with 1771 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
# NetworkUtils.ps1 — network detection utilities
# Requires $InternalRoot to be defined in the calling script's scope before dot-sourcing.
function Test-DnsSuffixConnected {
<#
.SYNOPSIS
Returns $true if any currently UP network adapter has a connection-specific
DNS suffix that contains the specified suffix string.
#>
[CmdletBinding()]
[OutputType([bool])]
param(
[Parameter(Mandatory)]
[string]$Suffix
)
try {
$clients = Get-DnsClient -ErrorAction Stop
foreach ($client in $clients) {
if ($client.ConnectionSpecificSuffix -notlike "*$Suffix*") { continue }
# Verify the adapter is actually connected/up
$adapter = Get-NetAdapter -InterfaceIndex $client.InterfaceIndex -ErrorAction SilentlyContinue
if ($adapter -and $adapter.Status -eq 'Up') {
return $true
}
}
return $false
}
catch {
Write-Log -Level Warn -Message "DNS suffix check failed for '$Suffix': $_" -Feature 'NetworkUtils'
return $false
}
}