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

New-PSDrive -Name AD2 -PSProvider FileSystem -Root "\\192.168.0.6\C$" -Credential $cred -ErrorAction Stop | Out-Null

Write-Host "[OK] Retrieving database documentation..."

# Get schema.sql
if (Test-Path "AD2:\Shares\testdatadb\database\schema.sql") {
    Get-Content "AD2:\Shares\testdatadb\database\schema.sql" -Raw | Out-File "D:\ClaudeTools\schema-retrieved.sql" -Encoding UTF8
    Write-Host "[OK] schema.sql retrieved"
}

# Get QUICKSTART.md
if (Test-Path "AD2:\Shares\testdatadb\QUICKSTART.md") {
    Get-Content "AD2:\Shares\testdatadb\QUICKSTART.md" -Raw | Out-File "D:\ClaudeTools\QUICKSTART-retrieved.md" -Encoding UTF8
    Write-Host "[OK] QUICKSTART.md retrieved"
}

# Get SESSION_NOTES.md
if (Test-Path "AD2:\Shares\testdatadb\SESSION_NOTES.md") {
    Get-Content "AD2:\Shares\testdatadb\SESSION_NOTES.md" -Raw | Out-File "D:\ClaudeTools\SESSION_NOTES-retrieved.md" -Encoding UTF8
    Write-Host "[OK] SESSION_NOTES.md retrieved"
}

# Get package.json
if (Test-Path "AD2:\Shares\testdatadb\package.json") {
    Get-Content "AD2:\Shares\testdatadb\package.json" -Raw | Out-File "D:\ClaudeTools\package-retrieved.json" -Encoding UTF8
    Write-Host "[OK] package.json retrieved"
}

Remove-PSDrive -Name AD2
Write-Host "[OK] All files retrieved"
