# Check for any remaining PLINK/PSCP references
$password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("INTRANET\sysadmin", $password)

Write-Host "=== Checking for PLINK/PSCP References ===" -ForegroundColor Cyan
Write-Host ""

Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
    $scriptPath = "C:\Shares\test\scripts\Sync-FromNAS.ps1"
    $content = Get-Content $scriptPath

    Write-Host "[1] Scanning for PLINK references" -ForegroundColor Yellow
    Write-Host "=" * 80 -ForegroundColor Gray

    for ($i = 0; $i -lt $content.Count; $i++) {
        if ($content[$i] -match 'PLINK|PSCP' -and $content[$i] -notmatch '^\s*#') {
            Write-Host "Line $($i+1): $($content[$i])" -ForegroundColor Red
        }
    }

    Write-Host ""
    Write-Host "[2] Showing variable definitions" -ForegroundColor Yellow
    Write-Host "=" * 80 -ForegroundColor Gray

    for ($i = 0; $i -lt $content.Count; $i++) {
        if ($content[$i] -match '^\$SCP\s*=|^\$SSH\s*=|^\$PLINK\s*=|^\$PSCP\s*=') {
            Write-Host "Line $($i+1): $($content[$i])" -ForegroundColor Cyan
        }
    }
}

Write-Host ""
Write-Host "=== Scan Complete ===" -ForegroundColor Cyan
