$ErrorActionPreference = 'Stop' Push-Location $PSScriptRoot try { if (-not (Get-Command node -ErrorAction SilentlyContinue)) { throw 'Node.js 24+ is required. Install it first, then run npm ci and npm start.' } $teamsNodeMajor = [int]((& node --version).Trim().TrimStart('v').Split('.')[0]) if ($teamsNodeMajor -lt 24) { throw 'Node.js 24+ is required.' } if (-not (Test-Path -LiteralPath (Join-Path $PSScriptRoot 'node_modules/@azure/msal-node'))) { & npm.cmd ci if ($LASTEXITCODE -ne 0) { throw 'Dependency installation failed.' } } & node --env-file-if-exists=.env src/main.js if ($LASTEXITCODE -ne 0) { throw "Collector stopped with exit code $LASTEXITCODE." } } finally { Pop-Location }