# Retrieve server.js for analysis
$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password)

Write-Host "[OK] Mounting AD2 C$ share..." -ForegroundColor Green
New-PSDrive -Name AD2 -PSProvider FileSystem -Root "\\192.168.0.6\C$" -Credential $cred -ErrorAction Stop | Out-Null

Write-Host "[OK] Retrieving server.js..." -ForegroundColor Green
$serverContent = Get-Content "AD2:\Shares\testdatadb\server.js" -Raw

$outputPath = "D:\ClaudeTools\server-js-retrieved.js"
$serverContent | Set-Content $outputPath -Encoding UTF8

Write-Host "[OK] Saved to: $outputPath" -ForegroundColor Green
Write-Host "[OK] File size: $($(Get-Item $outputPath).Length) bytes" -ForegroundColor Cyan

# Also get routes/api.js
Write-Host "`n[OK] Retrieving routes/api.js..." -ForegroundColor Green
if (Test-Path "AD2:\Shares\testdatadb\routes\api.js") {
    $apiContent = Get-Content "AD2:\Shares\testdatadb\routes\api.js" -Raw
    $apiOutputPath = "D:\ClaudeTools\api-js-retrieved.js"
    $apiContent | Set-Content $apiOutputPath -Encoding UTF8
    Write-Host "[OK] Saved to: $apiOutputPath" -ForegroundColor Green
    Write-Host "[OK] File size: $($(Get-Item $apiOutputPath).Length) bytes" -ForegroundColor Cyan
}

Remove-PSDrive -Name AD2 -ErrorAction SilentlyContinue
Write-Host "`n[OK] Done" -ForegroundColor Green
