<# .SYNOPSIS Read specific Confluence pages by ID and save locally .USAGE powershell -ExecutionPolicy Bypass -File scripts/confluence-read.ps1 -PageIds "123,456,789" #> param([string]$PageIds = "") . "$PSScriptRoot/../config.ps1" . "$PSScriptRoot/lib/confluence-api.ps1" Write-Host "=== Confluence Page Reader ===" -ForegroundColor Cyan if (-not $PageIds) { $PageIds = Read-Host "Enter page IDs (comma-separated)" } $Ids = $PageIds -split ',' | ForEach-Object { $_.Trim() } | Where-Object { $_ } $OutPath = Join-Path $ProjectDir "data/pages" New-Item -ItemType Directory -Path $OutPath -Force | Out-Null foreach ($Id in $Ids) { Write-Host "" Write-Host ">> Page $Id" -ForegroundColor Yellow $Page = Get-PageContent -PageId $Id if (-not $Page) { continue } Write-Host " Title: $($Page.title) (v$($Page.version.number))" -ForegroundColor Green $HtmlContent = "" if ($Page.body -and $Page.body.storage) { $HtmlContent = $Page.body.storage.value } $TextContent = Convert-HtmlToText $HtmlContent $SafeTitle = $Page.title -replace '[\\/:*?"<>|]', '_' $HtmlContent | Out-File "$OutPath/$($Page.id)_$SafeTitle.html" -Encoding UTF8 $TextContent | Out-File "$OutPath/$($Page.id)_$SafeTitle.md" -Encoding UTF8 Write-Host " Saved ($($HtmlContent.Length) chars)" } Write-Host "" Write-Host "Done! Files in $OutPath" -ForegroundColor Green