Correction d'encodage de caractère

Correction de fichier non trouvé
This commit is contained in:
benoit committed 2026-10-17 15:09:58 +02:00
1 parent 8d5014b4aa
commit 2019c565f5
5 files changed
+74 -30

No files matched your search

+2 -2
View File
@@ -30,8 +30,8 @@ function Read-DeployCenterConfig {
$config.VncPassword = $value
} elseif ($section -ieq 'Partitioning' -and $key -ieq 'WinRESizeMB') {
$sizeMB = 0
if (-not [int]::TryParse($value, [ref]$sizeMB) -or $sizeMB -lt 990) {
throw "Le paramètre [Partitioning] WinRESizeMB doit être un entier supérieur ou égal à 990. Valeur reçue : '$value'."
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
}
+59 -22
View File
@@ -80,7 +80,7 @@ function New-DeployCenterDismSourceAccess {
Invoke-DeployCenterNativeCommand -FilePath $mountVolPath -Arguments @(("{0}:\" -f $letter), '/D') `
-TemporaryRoot $TemporaryRoot -LogAction $LogAction
} catch { }
throw "La source Windows n’est pas accessible après l’affectation temporaire de $letter`:."
throw "La source Windows n’est pas accessible après l’affectation temporaire de ${letter}:."
}
if ($mountError) {
Write-DeployCenterDeploymentLog -LogAction $LogAction `
@@ -184,9 +184,11 @@ function Invoke-DeployCenterNativeCommand {
$process.Refresh()
$exitCode = $process.ExitCode
$nativeOutputLines = New-Object System.Collections.Generic.List[string]
$nativeOutputEncoding = [System.Console]::OutputEncoding
if ($null -eq $nativeOutputEncoding) { $nativeOutputEncoding = [System.Text.Encoding]::Default }
foreach ($outputPath in @($stdoutPath, $stderrPath)) {
if (Test-Path -LiteralPath $outputPath -PathType Leaf) {
foreach ($line in [System.IO.File]::ReadAllLines($outputPath)) {
foreach ($line in [System.IO.File]::ReadAllLines($outputPath, $nativeOutputEncoding)) {
if (-not [string]::IsNullOrWhiteSpace($line)) {
[void]$nativeOutputLines.Add([string]$line)
Write-DeployCenterDeploymentLog -LogAction $LogAction -Message ([string]$line) -Level 'INFO'
@@ -213,6 +215,23 @@ function Invoke-DeployCenterNativeCommand {
-Level 'WARNING'
return
}
if ($null -eq $exitCode -and [IO.Path]::GetFileName($FilePath) -ieq 'bcdboot.exe') {
$bootOutput = ($nativeOutputLines -join "`n").Normalize([System.Text.NormalizationForm]::FormD) -replace '\p{Mn}', ''
$bootFilesCreated = $bootOutput -match '(?i)boot files successfully created|fichiers de d\s*marrage.*bien.*cr'
$systemArgumentIndex = [array]::IndexOf($Arguments, '/s')
$bcdStoreExists = $false
if ($systemArgumentIndex -ge 0 -and $systemArgumentIndex + 1 -lt $Arguments.Count) {
$systemRoot = ([string]$Arguments[$systemArgumentIndex + 1]).TrimEnd('\')
$bcdStorePath = "${systemRoot}\EFI\Microsoft\Boot\BCD"
$bcdStoreExists = Test-Path -LiteralPath $bcdStorePath -PathType Leaf
}
if ($bootFilesCreated -or $bcdStoreExists) {
Write-DeployCenterDeploymentLog -LogAction $LogAction `
-Message "bcdboot a créé les fichiers de démarrage, mais WinPE n’a pas fourni de code de sortie exploitable. La création est confirmée." `
-Level 'WARNING'
return
}
}
if ($null -eq $exitCode -or [int]$exitCode -ne 0) {
$diagnostic = @()
if ($isDism -and (Test-Path -LiteralPath $dismLogPath -PathType Leaf)) {
@@ -221,7 +240,8 @@ function Invoke-DeployCenterNativeCommand {
Write-DeployCenterDeploymentLog -LogAction $LogAction -Message ("DISM : {0}" -f $line) -Level 'ERROR'
}
}
throw "La commande '$FilePath' s'est terminée avec le code '$exitCode'. $(($diagnostic -join ' | '))"
$diagnosticMessage = $diagnostic -join ' | '
throw ("La commande {0} s'est terminée avec le code {1}. {2}" -f $FilePath, $exitCode, $diagnosticMessage)
}
} finally {
foreach ($outputPath in @($stdoutPath, $stderrPath)) {
@@ -271,7 +291,7 @@ function Get-DeployCenterTemporaryDriveLetters {
}
if (-not $selected) { throw "Aucune lettre de lecteur libre pour la partition '$($partition.Name)'." }
}
if ($selected -in $lettersByRole.Values) { throw "La lettre $selected`: est affectée à plusieurs partitions du profil." }
if ($selected -in $lettersByRole.Values) { throw "La lettre ${selected}: est affectée à plusieurs partitions du profil." }
$lettersByRole[[string]$partition.Role] = $selected
$occupied[$selected] = $true
}
@@ -357,10 +377,10 @@ function Invoke-DeployCenterWindowsDeployment {
)
if ($HostName -notmatch '^(?=.*[A-Za-z])[A-Za-z0-9](?:[A-Za-z0-9-]{0,13}[A-Za-z0-9])?$') {
throw "Le nom d'hôte doit respecter les règles NetBIOS et ne pas dépasser 15 caractères."
throw 'Le nom de machine doit respecter les règles NetBIOS et ne pas dépasser 15 caractères.'
}
if ([string]$Firmware -ne [string]$Profile.Firmware) {
throw "Le profil '$($Profile.Name)' exige le firmware $($Profile.Firmware), détecté : $Firmware."
throw ("Le profil {0} exige le firmware {1}, détecté : {2}." -f $Profile.Name, $Profile.Firmware, $Firmware)
}
foreach ($requiredRole in @('System','Reserved','Recovery','Windows')) {
$roleCount = @($Profile.Partitions | Where-Object { [string]$_.Role -eq $requiredRole }).Count
@@ -371,8 +391,8 @@ function Invoke-DeployCenterWindowsDeployment {
throw "Le profil doit définir une taille configurée pour la partition Recovery. Le disque n’a pas été modifié."
}
$winrePartitionSizeMB = [long]$recoveryDefinitions[0].Size.Value
if ($winrePartitionSizeMB -lt 990) {
throw "La partition WinRE doit être configurée à au moins 990 Mo. Le disque n’a pas été modifié."
if ($winrePartitionSizeMB -le 0) {
throw "La taille configurée de la partition WinRE doit être strictement positive. Le disque n’a pas été modifié."
}
if (-not $Edition.ImagePath -or -not (Test-Path -LiteralPath ([string]$Edition.ImagePath) -PathType Leaf)) {
throw "Le chemin de l’image Windows sélectionnée est introuvable."
@@ -399,8 +419,6 @@ function Invoke-DeployCenterWindowsDeployment {
if (-not (Test-Path -LiteralPath $dismPath -PathType Leaf)) { $dismPath = 'dism.exe' }
$bcdbootPath = Join-Path $env:WINDIR 'System32\bcdboot.exe'
if (-not (Test-Path -LiteralPath $bcdbootPath -PathType Leaf)) { $bcdbootPath = 'bcdboot.exe' }
$reagentcPath = Join-Path $env:WINDIR 'System32\reagentc.exe'
if (-not (Test-Path -LiteralPath $reagentcPath -PathType Leaf)) { $reagentcPath = 'reagentc.exe' }
$scriptLines = New-Object System.Collections.Generic.List[string]
$scriptLines.Add("select disk $($disk.Number)")
@@ -454,7 +472,7 @@ function Invoke-DeployCenterWindowsDeployment {
$letter = [string]$driveLetters[$role]
$driveRoot = '{0}:\' -f $letter
if (-not (Test-Path -LiteralPath $driveRoot -PathType Container)) {
throw "La lettre temporaire $letter`: n’est pas accessible après le partitionnement. L’installation est interrompue."
throw "La lettre temporaire ${letter}: n’est pas accessible après le partitionnement. L’installation est interrompue."
}
# WinPE peut ne pas exposer les partitions EFI/Recovery dans les
# requêtes Get-Partition par lettre. Leur ordre sur le disque suit
@@ -472,7 +490,7 @@ function Invoke-DeployCenterWindowsDeployment {
throw "Le profil doit définir les rôles System, Windows et Recovery pour permettre l’installation UEFI avec WinRE."
}
if ($ProgressAction) { & $ProgressAction "Application de Windows sur $windowsLetter`:…" }
if ($ProgressAction) { & $ProgressAction "Application de Windows sur ${windowsLetter}:…" }
Invoke-DeployCenterNativeCommand -FilePath $dismPath -Arguments @(
'/Apply-Image', "/ImageFile:$deploymentImagePath", "/Index:$([int]$Edition.Index)", "/ApplyDir:$windowsPath", '/CheckIntegrity'
) -TemporaryRoot $TemporaryRoot -LogAction $LogAction -ProgressAction $ProgressAction
@@ -486,23 +504,35 @@ function Invoke-DeployCenterWindowsDeployment {
$recoveryPartition = $partitionsByLetter[$recoveryLetter]
$recoveryDriveInfo = New-Object System.IO.DriveInfo -ArgumentList "${recoveryLetter}:\"
if (-not $recoveryDriveInfo.IsReady) {
throw "Le volume de récupération $recoveryLetter`: n’est pas prêt pour vérifier l’espace WinRE."
throw "Le volume de récupération ${recoveryLetter}: n’est pas prêt pour vérifier l’espace WinRE."
}
$minimumPartitionBytes = [long](990 * 1MB)
$minimumFreeBytes = [long]($winreFile.Length + (250 * 1MB))
$minimumFreeAfterCopyBytes = [long](250 * 1MB)
$recoveryFreeBytes = [long]$recoveryDriveInfo.AvailableFreeSpace
$expectedFreeBytes = $recoveryFreeBytes - [long]$winreFile.Length
if ([long]$recoveryPartition.Size -lt $minimumPartitionBytes -or
$recoveryFreeBytes -lt $minimumFreeBytes) {
$winreSizeForLog = [math]::Ceiling(([double]$winreFile.Length / 1MB))
$availableAfterCopyMB = [math]::Floor(([double]$expectedFreeBytes / 1MB))
$message = "La partition WinRE configurée à $winrePartitionSizeMB Mo ne respecte pas les prérequis Microsoft : taille de winre.wim $winreSizeForLog Mo, espace libre requis après copie 250 Mo, estimé $availableAfterCopyMB Mo. L’installation est interrompue avant l’activation de WinRE."
$winreSizeForLog = [math]::Ceiling(([double]$winreFile.Length / 1MB))
$availableFreeMB = [math]::Floor(([double]$recoveryFreeBytes / 1MB))
$availableAfterCopyMB = [math]::Floor(([double]$expectedFreeBytes / 1MB))
if ($recoveryFreeBytes -lt [long]$winreFile.Length) {
$message = "Espace insuffisant sur la partition WinRE pour copier winre.wim : fichier de $winreSizeForLog Mo, espace disponible $availableFreeMB Mo. Le déploiement ne peut pas configurer WinRE."
Write-DeployCenterDeploymentLog -LogAction $LogAction -Message $message -Level 'ERROR'
throw $message
}
$winreSizeForLog = [math]::Ceiling(([double]$winreFile.Length / 1MB))
$availableAfterCopyMB = [math]::Floor(([double]$expectedFreeBytes / 1MB))
Write-DeployCenterDeploymentLog -LogAction $LogAction -Message ("Vérification WinRE réussie : partition {0} Mo, winre.wim {1} Mo, espace restant estimé après copie {2} Mo." -f $winrePartitionSizeMB, $winreSizeForLog, $availableAfterCopyMB) -Level 'SUCCESS'
$recommendationWarnings = New-Object System.Collections.Generic.List[string]
if ([long]$recoveryPartition.Size -lt $minimumPartitionBytes) {
$actualPartitionMB = [math]::Floor(([double]$recoveryPartition.Size / 1MB))
[void]$recommendationWarnings.Add("taille de partition : $actualPartitionMB Mo, minimum recommandé : 990 Mo")
}
if ($expectedFreeBytes -lt $minimumFreeAfterCopyBytes) {
[void]$recommendationWarnings.Add("espace libre après copie : $availableAfterCopyMB Mo, minimum recommandé : 250 Mo")
}
if ($recommendationWarnings.Count -gt 0) {
$warningDetails = $recommendationWarnings -join '; '
$message = "Avertissement WinRE : les recommandations Microsoft ne sont pas toutes respectées ($warningDetails). La copie de winre.wim reste possible ; le déploiement continue."
Write-DeployCenterDeploymentLog -LogAction $LogAction -Message $message -Level 'WARNING'
} else {
Write-DeployCenterDeploymentLog -LogAction $LogAction -Message ("Vérification WinRE réussie : partition {0} Mo, winre.wim {1} Mo, espace restant estimé après copie {2} Mo." -f $winrePartitionSizeMB, $winreSizeForLog, $availableAfterCopyMB) -Level 'SUCCESS'
}
if ($ProgressAction) { & $ProgressAction "Configuration du nom d’hôte…" }
$editionArchitecture = if ($Edition.Edition -and $Edition.Edition.Architecture) { [string]$Edition.Edition.Architecture } else { [string]$Edition.Architecture }
@@ -520,6 +550,13 @@ function Invoke-DeployCenterWindowsDeployment {
if ($ProgressAction) { & $ProgressAction 'Configuration de la partition de récupération WinRE…' }
New-Item -Path $recoveryPath -ItemType Directory -Force -ErrorAction Stop | Out-Null
Copy-Item -LiteralPath $sourceWinre -Destination (Join-Path $recoveryPath 'winre.wim') -Force -ErrorAction Stop
$reagentcPath = Join-Path $windowsRoot 'System32\reagentc.exe'
if (-not (Test-Path -LiteralPath $reagentcPath -PathType Leaf)) {
$reagentcPath = Join-Path $env:WINDIR 'System32\reagentc.exe'
}
if (-not (Test-Path -LiteralPath $reagentcPath -PathType Leaf)) {
throw 'REAgentC.exe est introuvable dans Windows appliqué et dans WinPE.'
}
Invoke-DeployCenterNativeCommand -FilePath $reagentcPath -Arguments @(
'/SetReImage', '/Path', $recoveryPath, '/Target', $windowsRoot
) -TemporaryRoot $TemporaryRoot -LogAction $LogAction -ProgressAction $ProgressAction
+2 -2
View File
@@ -58,8 +58,8 @@ function Import-DeployCenterPartitionProfile {
}
'ConfiguredMB' {
if ([string]::IsNullOrWhiteSpace([string]$partition.Size.ConfigKey) -or
[int]$partition.Size.Value -lt 990 -or [int]$partition.Size.PreviewMB -lt 990) {
throw "La taille configurée de la partition '$($partition.Name)' du profil '$ProfileName' doit définir ConfigKey et une valeur d’au moins 990 Mo."
[int]$partition.Size.Value -le 0 -or [int]$partition.Size.PreviewMB -le 0) {
throw "La taille configurée de la partition '$($partition.Name)' du profil '$ProfileName' doit définir ConfigKey et des tailles strictement positives."
}
}
'UserInputGB' {