??param( [Parameter(Mandatory=$true)][string]$StarterPath ) $ErrorActionPreference='Stop' $GOV_ROOT="\\DS-918\chatgpt\ChatGPT-Gouvernance-Projets\_registry" $RUN_CMD = Join-Path $GOV_ROOT 'scripts\run_in_govshell.cmd' if(!(Test-Path $RUN_CMD)){ throw "run_in_govshell.cmd introuvable: $RUN_CMD" } if(!(Test-Path $StarterPath)){ throw "Starter introuvable: $StarterPath" } # Lire le .txt (UTF-8 si possible, sinon encodage par d?faut) try { $text=[IO.File]::ReadAllText($StarterPath,[Text.Encoding]::UTF8) } catch { $text=[IO.File]::ReadAllText($StarterPath) } # ?crire un .ps1 temporaire (UTF-8 BOM) et l'ex?cuter via GOV Shell $tmpDir='C:\Temp_Gouvernance'; if(!(Test-Path $tmpDir)){ New-Item -ItemType Directory -Force -Path $tmpDir|Out-Null } $tmp = Join-Path $tmpDir ("starter_" + [IO.Path]::GetFileNameWithoutExtension($StarterPath) + '_' + (Get-Date -Format 'yyyyMMdd_HHmmss') + '.ps1') [IO.File]::WriteAllText($tmp,$text,(New-Object Text.UTF8Encoding($true))) & $RUN_CMD $tmp # Log l?ger $log = Join-Path $GOV_ROOT 'logs\registry_activity.log' $old=@(); if(Test-Path $log){ $old += Get-Content -LiteralPath $log -ErrorAction SilentlyContinue } $old += ("[{0}] starter_run: path={1}" -f (Get-Date -Format 'yyyy-MM-ddTHH:mm:ssK'),$StarterPath) [IO.File]::WriteAllText($log,($old -join "`r`n"),(New-Object Text.UTF8Encoding($false))) Write-Host "[STARTER] lanc? via GOV Shell -> $StarterPath"