Ajout de la configuration de paritionnement des disques

This commit is contained in:
benoit committed 2026-10-15 23:05:30 +02:00
1 parent 7c724d475e
commit e388cdca45
9 files changed
+450 -123

No files matched your search

+18 -6
View File
@@ -8,7 +8,6 @@ function Start-DeployCenterVnc {
$passwordTool = Join-Path $sourceVnc 'createpassword64.exe'
$sourceIni = Join-Path $sourceVnc 'ultravnc.ini'
$script:DeployIPv4 = Get-DeployNetworkIPv4
if ([string]::IsNullOrWhiteSpace($script:DeployIPv4)) {
Write-Log 'Aucune adresse IPv4 de déploiement détectée.' 'WARNING'
}
@@ -29,25 +28,36 @@ function Start-DeployCenterVnc {
return
}
$vncStage = 'préparation du dossier temporaire'
try {
if (Test-Path -LiteralPath $script:VncDirectory) {
Remove-Item -LiteralPath $script:VncDirectory -Recurse -Force -ErrorAction Stop
}
New-Item -Path $script:VncDirectory -ItemType Directory -Force | Out-Null
$vncStage = "copie des fichiers depuis $sourceVnc vers $script:VncDirectory"
Copy-Item -Path (Join-Path $sourceVnc '*') -Destination $script:VncDirectory -Recurse -Force
# WinPE ne permet pas toujours d'ajouter des règles de pare-feu.
# La désactivation globale n'est effectuée que lorsque VNC est demandé.
$vncStage = 'désactivation du pare-feu WinPE'
$wpeutil = Join-Path $env:WINDIR 'System32\wpeutil.exe'
if (-not (Test-Path -LiteralPath $wpeutil -PathType Leaf)) {
$wpeutil = 'wpeutil.exe'
}
& $wpeutil DisableFirewall
if ($LASTEXITCODE -ne 0) {
throw "wpeutil DisableFirewall a renvoyé le code $LASTEXITCODE."
$wpeutilOutput = @(& $wpeutil DisableFirewall 2>&1)
$wpeutilExitCode = $LASTEXITCODE
foreach ($outputLine in $wpeutilOutput) {
$outputText = [string]$outputLine
if (-not [string]::IsNullOrWhiteSpace($outputText)) {
Write-Log "wpeutil DisableFirewall : $outputText" 'INFO'
}
}
Write-Log 'Pare-feu WinPE désactivé à la demande de -Vnc.' 'WARNING'
if ($wpeutilExitCode -ne 0) {
throw "wpeutil DisableFirewall a renvoyé le code $wpeutilExitCode."
}
Write-Log "Pare-feu WinPE désactivé à la demande de -Vnc (code wpeutil : $wpeutilExitCode)." 'WARNING'
# Force le mode portable : l'INI actif est celui placé à côté de winvnc.exe.
$vncStage = 'activation du mode portable UltraVNC'
$portableFlag = Join-Path $script:VncDirectory 'ultravnc.portable'
Set-Content -LiteralPath $portableFlag -Value '' -Encoding ASCII
@@ -64,6 +74,7 @@ function Start-DeployCenterVnc {
}
# createpassword64 encode le mot de passe choisi dans le champ passwd d'ultravnc.ini.
$vncStage = 'génération du mot de passe UltraVNC'
$tool = Join-Path $script:VncDirectory 'createpassword64.exe'
$script:VncProcess = Start-Process -FilePath $tool -ArgumentList @($script:VncPassword) `
-WorkingDirectory $script:VncDirectory -Wait -PassThru -WindowStyle Hidden
@@ -78,6 +89,7 @@ function Start-DeployCenterVnc {
}
$server = Join-Path $script:VncDirectory 'winvnc.exe'
$vncStage = 'démarrage du serveur UltraVNC'
$script:VncProcess = Start-Process -FilePath $server -ArgumentList @('-run') `
-WorkingDirectory $script:VncDirectory -PassThru -WindowStyle Hidden
Start-Sleep -Milliseconds 800
@@ -87,7 +99,7 @@ function Start-DeployCenterVnc {
$script:VncStarted = $true
Write-Log "UltraVNC démarré. IP : $($script:DeployIPv4) ; mot de passe $passwordSource." 'SUCCESS'
} catch {
Write-Log "Échec du démarrage UltraVNC : $($_.Exception.Message)" 'ERROR'
Write-Log "Échec du démarrage UltraVNC à l'étape '$vncStage' : $($_.Exception.Message)" 'ERROR'
$script:VncStarted = $false
$script:VncPassword = $null
}