$ErrorActionPreference = 'Stop'
$expected = '__IMAGE_VERSION__'
$actual = (Get-Content -LiteralPath 'C:\ProgramData\Workshopz\image-version.txt' -Raw).Trim()
if ($actual -ne $expected) { throw "Expected image version $expected but found $actual." }
if (-not (Get-WindowsFeature Web-Server).Installed) { throw 'IIS is not installed.' }
if (-not (Test-Path -LiteralPath 'C:\ProgramData\Workshopz\build-manifest.json')) { throw 'Build manifest is missing.' }
$manifest = Get-Content -LiteralPath 'C:\ProgramData\Workshopz\build-manifest.json' -Raw | ConvertFrom-Json
if (-not [bool]$manifest.IisInstalled) { throw 'The manifest did not record the IIS baseline.' }
$response = Invoke-WebRequest -Uri 'http://localhost/' -UseBasicParsing -TimeoutSec 20
if ($response.StatusCode -ne 200 -or $response.Content -notmatch [regex]::Escape($expected)) { throw 'The versioned IIS health page failed validation.' }
