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

Write-Host "[OK] Retrieving Sync-FromNAS.ps1 from AD2..."
$scriptContent = Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
    Get-Content C:\Shares\test\scripts\Sync-FromNAS.ps1 -Raw
}

$scriptContent | Out-File -FilePath "D:\ClaudeTools\Sync-FromNAS-retrieved.ps1" -Encoding UTF8
Write-Host "[OK] Script saved to D:\ClaudeTools\Sync-FromNAS-retrieved.ps1"

Write-Host "`n[OK] Searching for database folder..."
$dbFolders = Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
    Get-ChildItem C:\ -Directory -ErrorAction SilentlyContinue | Where-Object Name -match "database|testdata|test.*db"
}

if ($dbFolders) {
    Write-Host "`nFound folders:"
    $dbFolders | Format-Table Name, FullName
} else {
    Write-Host "No database folders found in C:\"
}
