# Find TS-XX machine folders with Backup subdirectories
$testPath = "\\192.168.0.6\test"

Write-Host "Searching for TS-XX machine folders with Backup subdirectories..."
Write-Host ""

# Get all directories matching TS-*
$tsFolders = Get-ChildItem -Path $testPath -Directory -Filter "TS-*" -ErrorAction SilentlyContinue

if ($tsFolders) {
    Write-Host "Found $($tsFolders.Count) TS-XX folders:"
    Write-Host ""

    foreach ($folder in $tsFolders) {
        $backupPath = Join-Path $folder.FullName "Backup"

        Write-Host "Machine: $($folder.Name)"

        if (Test-Path $backupPath) {
            Write-Host "  [OK] Backup folder exists: $backupPath"

            # Check for files in backup folder
            $backupFiles = Get-ChildItem -Path $backupPath -ErrorAction SilentlyContinue
            if ($backupFiles) {
                Write-Host "  Files: $($backupFiles.Count) items"

                # Show most recent file
                $latestFile = $backupFiles | Where-Object { -not $_.PSIsContainer } | Sort-Object LastWriteTime -Descending | Select-Object -First 1
                if ($latestFile) {
                    Write-Host "  Latest: $($latestFile.Name)"
                    Write-Host "  Date: $($latestFile.LastWriteTime)"
                    Write-Host "  Size: $([math]::Round($latestFile.Length / 1KB, 2)) KB"
                }
            } else {
                Write-Host "  [EMPTY] No files in backup folder"
            }
        } else {
            Write-Host "  [MISSING] No Backup folder"
        }

        Write-Host ""
    }
} else {
    Write-Host "No TS-XX folders found in $testPath"
}

Write-Host "Search complete."
