Files
Bastion-Stid/template/http/s4_dotNet.ps1
Serge NOELandClaude Opus 5.5 1e2bcf21cf Regroupement de la chaîne de tests de charge beWeapon
- template/ : build Packer du template Windows 11 (ex /data/Installer/MyTemplate)
- deploy/   : OpenTofu + playbooks Ansible (ex /data/Tofu)
- bin/Deploy : menu de déploiement (lien depuis /usr/local/bin/Deploy)
- jeton API Proxmox sorti des playbooks vers deploy/proxmox-secret.yml (hors git)
- README.md : documentation de la structure et du mode opératoire
- Ameliorations.md : recommandations pour fiabiliser les mesures
- tests/ (dépôt beWeapon-LT) et archives/ exclus

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 15:27:51 +01:00

87 lines
3.3 KiB
PowerShell

Set-ExecutionPolicy Bypass -Scope Process -Force
function Write-Log {
param ([string]$Message)
"$Message" | Out-File -FilePath "C:\install.log" -Append -Encoding utf8
}
# Logs initiaux
Write-Log "=== Configuration et installation de .NET Framework 3.5 ==="
Write-Host "=== Configuration et installation de .NET Framework 3.5 ===" -ForegroundColor Cyan
# 1. Verification si .NET 3.5 est deja installe
$net35Status = Get-WindowsOptionalFeature -Online -FeatureName "NetFx3" -ErrorAction SilentlyContinue
if ($net35Status -and $net35Status.State -eq "Enabled") {
Write-Log ".NET Framework 3.5 est deja active sur cette machine."
Write-Host ".NET Framework 3.5 est deja active." -ForegroundColor Green
exit 0
}
# 2. Recherche precise d'un fichier .cab ou du dossier sxs contenant les sources .NET 3.5
$cdDrives = Get-PSDrive -PSProvider FileSystem | Where-Object { $_.Free -ne $null -or $_.Used -ne $null }
$validSxsSource = $null
foreach ($drive in $cdDrives) {
$pathsToTest = @(
"$($drive.Name):\sources\sxs",
"$($drive.Name):\install\sxs",
"$($drive.Name):\install"
)
foreach ($path in $pathsToTest) {
if (Test-Path $path) {
# Verification qu'un fichier cab lie a NetFx3 existe bien dans le dossier
$cabFile = Get-ChildItem -Path $path -Filter "*netfx3*.cab" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($cabFile) {
$validSxsSource = $path
break
}
}
}
if ($validSxsSource) { break }
}
# 3. Tentative d'installation (Source locale puis Windows Update)
$installedSuccessfully = $false
if ($validSxsSource) {
Write-Log "Fichiers sources .NET 3.5 trouves dans : $validSxsSource"
Write-Host "Installation depuis la source locale ($validSxsSource)..." -ForegroundColor Yellow
try {
Enable-WindowsOptionalFeature -Online -FeatureName "NetFx3" -Source $validSxsSource -LimitAccess -All -NoRestart -ErrorAction Stop | Out-Null
$installedSuccessfully = $true
} catch {
Write-Warning "L'installation hors-ligne a echoue. Tentative via Windows Update..."
Write-Log "AVERTISSEMENT : Echec de l'installation hors-ligne depuis $validSxsSource : $_"
}
}
# Fallback sur Windows Update / DISM en ligne si pas de source locale valide ou en cas d'échec
if (-not $installedSuccessfully) {
Write-Log "Tentative d'installation de .NET 3.5 via Windows Update..."
Write-Host "Installation via Windows Update en cours..." -ForegroundColor Yellow
try {
# Utilisation de DISM directement pour autoriser le telechargement en ligne
$dismResult = DISM.exe /Online /Enable-Feature /FeatureName:NetFx3 /All /Quiet /NoRestart
if ($LASTEXITCODE -eq 0) {
$installedSuccessfully = $true
} else {
throw "DISM a retourne le code d'erreur $LASTEXITCODE"
}
} catch {
Write-Error "Echec de l'installation de .NET Framework 3.5 : $_"
Write-Log "ERREUR lors de l'installation de .NET 3.5 : $_"
exit 1
}
}
if ($installedSuccessfully) {
Write-Log ".NET Framework 3.5 a ete installe avec succes."
Write-Host ".NET Framework 3.5 installe avec succes." -ForegroundColor Green
}
Write-Log "=== Fin de l'installation de .NET Framework 3.5 ==="