Files
DeployCenter/Modules/Configuration.psm1
T
benoit cb917c97ce Ajout d'un fond d'écran personnalisé si fourni dans DeployCenter.ini
Renommage du profil unattend pour mieux correspondre à ce qu'il fait.
Ajout d'un warning si WinRE n'est pas assez grands au regard des préconisations Microsoft et du redémarrage automatique si l'installation réussi.
2026-10-17 21:28:34 +02:00

64 lines
2.9 KiB
PowerShell

# DeployCenter - Lecture des préférences utilisateur
# Lecture seule : ce module ne modifie jamais DeployCenter.ini.
function Read-DeployCenterConfig {
[CmdletBinding()]
param([Parameter(Mandatory=$true)][string]$ConfigPath)
$config = @{
Theme = 'Light'
SourcePaths = '%DEPLOY_VOLUME%'
VncPassword = ''
WinRESizeMB = 1024
UnattendAdminName = 'admin'
UnattendAdminDisplayName = 'Administrateur local'
UnattendAdminGroup = 'Administrators'
UnattendAdminPasswordBase64 = ''
UnattendSupportProvider = ''
UnattendSupportAppURL = ''
UnattendWallpaperPath = 'Assets\blorand.png'
}
if (-not (Test-Path -LiteralPath $ConfigPath -PathType Leaf)) { return $config }
$section = ''
foreach ($line in (Get-Content -LiteralPath $ConfigPath -ErrorAction SilentlyContinue)) {
$trimmed = $line.Trim()
if (-not $trimmed -or $trimmed.StartsWith(';') -or $trimmed.StartsWith('#')) { continue }
if ($trimmed -match '^\[(.+)\]$') { $section = $matches[1].Trim(); continue }
if ($trimmed -notmatch '^([^=]+)=(.*)$') { continue }
$key = $matches[1].Trim()
$value = $matches[2].Trim()
if ($section -ieq 'General' -and $key -ieq 'Theme' -and $value -match '^[A-Za-z0-9_-]+$') {
$config.Theme = $value
} elseif ($section -ieq 'Sources' -and $key -ieq 'Paths') {
$config.SourcePaths = $value
} elseif ($section -ieq 'UltraVNC' -and $key -ieq 'Password') {
$config.VncPassword = $value
} elseif ($section -ieq 'Partitioning' -and $key -ieq 'WinRESizeMB') {
$sizeMB = 0
if (-not [int]::TryParse($value, [ref]$sizeMB) -or $sizeMB -le 0) {
throw "Le paramètre [Partitioning] WinRESizeMB doit être un entier strictement positif. Valeur reçue : '$value'."
}
$config.WinRESizeMB = $sizeMB
} elseif ($section -ieq 'Unattend' -and $key -ieq 'AdminName') {
$config.UnattendAdminName = $value
} elseif ($section -ieq 'Unattend' -and $key -ieq 'AdminDisplayName') {
$config.UnattendAdminDisplayName = $value
} elseif ($section -ieq 'Unattend' -and $key -ieq 'AdminGroup') {
$config.UnattendAdminGroup = $value
} elseif ($section -ieq 'Unattend' -and $key -ieq 'AdminPasswordBase64') {
$config.UnattendAdminPasswordBase64 = $value
} elseif ($section -ieq 'Unattend' -and $key -ieq 'SupportProvider') {
$config.UnattendSupportProvider = $value
} elseif ($section -ieq 'Unattend' -and $key -ieq 'SupportAppURL') {
$config.UnattendSupportAppURL = $value
} elseif ($section -ieq 'Unattend' -and $key -ieq 'WallpaperPath') {
$config.UnattendWallpaperPath = $value
}
}
return $config
}
Export-ModuleMember -Function Read-DeployCenterConfig