Move 150+ scripts from root and scripts/ into client/project directories: - clients/dataforth/scripts/ (110 files: AD2, sync, SSH, DB, DOS scripts) - clients/bg-builders/scripts/ (14 files: Lesley mgmt, Exchange, termination) - clients/internal-infrastructure/scripts/ (10 files: GDAP, Gitea, backups) - projects/msp-tools/scripts/ (9 files: CIPP, MSP onboarding, Datto) - projects/gururmm-agent/scripts/ (3 files: API test, JWT, record counts) - clients/glaztech/scripts/ (1 file: CentraStage removal) Also reorganized: - VPN scripts → infrastructure/vpn-configs/ - Retrieved API/JS files → api/ - Forum posts → projects/community-forum/forum-posts/ - SSH docs → clients/internal-infrastructure/docs/ - NWTOC/CTONW docs → projects/wrightstown-smarthome/docs/ - ACG website files → projects/internal/acg-website-2025/ - Dataforth docs → clients/dataforth/docs/ - schema-retrieved.sql → docs/database/ Deleted 24 tmp_*.ps1 one-off debug scripts (preserved in git history). Root reduced from 220+ files to 62 items (docs + directories only). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
102 lines
3.8 KiB
PowerShell
102 lines
3.8 KiB
PowerShell
# Trigger sync immediately and monitor results
|
|
$password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
|
|
$cred = New-Object System.Management.Automation.PSCredential("INTRANET\sysadmin", $password)
|
|
|
|
Write-Host "=== Triggering Sync Manually ===" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
|
|
$scriptPath = "C:\Shares\test\scripts\Sync-FromNAS.ps1"
|
|
$logFile = "C:\Shares\test\scripts\sync-from-nas.log"
|
|
|
|
Write-Host "[1] Getting current log position" -ForegroundColor Yellow
|
|
$logSize = (Get-Item $logFile).Length
|
|
Write-Host "[OK] Current log size: $logSize bytes" -ForegroundColor Green
|
|
|
|
Write-Host ""
|
|
Write-Host "[2] Starting sync script..." -ForegroundColor Yellow
|
|
Write-Host "=" * 80 -ForegroundColor Gray
|
|
|
|
# Run sync script and capture output
|
|
$syncStart = Get-Date
|
|
|
|
try {
|
|
& powershell.exe -ExecutionPolicy Bypass -File $scriptPath *>&1 | Out-String -Stream | ForEach-Object {
|
|
if ($_ -match "ERROR|error") {
|
|
Write-Host $_ -ForegroundColor Red
|
|
} elseif ($_ -match "Pushed|Pulled") {
|
|
Write-Host $_ -ForegroundColor Green
|
|
} elseif ($_ -match "Starting|Complete|sync") {
|
|
Write-Host $_ -ForegroundColor Cyan
|
|
} else {
|
|
Write-Host $_ -ForegroundColor Gray
|
|
}
|
|
}
|
|
} catch {
|
|
Write-Host "[ERROR] Sync script failed: $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
|
|
$syncEnd = Get-Date
|
|
$duration = ($syncEnd - $syncStart).TotalSeconds
|
|
|
|
Write-Host ""
|
|
Write-Host "=" * 80 -ForegroundColor Gray
|
|
Write-Host "[3] Sync completed in $([math]::Round($duration, 1)) seconds" -ForegroundColor Yellow
|
|
|
|
Write-Host ""
|
|
Write-Host "[4] Analyzing new log entries" -ForegroundColor Yellow
|
|
Write-Host "=" * 80 -ForegroundColor Gray
|
|
|
|
# Get new log content
|
|
Start-Sleep -Seconds 2
|
|
$newLogSize = (Get-Item $logFile).Length
|
|
$newBytes = $newLogSize - $logSize
|
|
|
|
if ($newBytes -gt 0) {
|
|
$allContent = Get-Content $logFile -Raw
|
|
$newContent = $allContent.Substring([math]::Max(0, $allContent.Length - $newBytes - 100))
|
|
|
|
Write-Host "New log entries ($newBytes bytes):" -ForegroundColor Cyan
|
|
$newContent -split "`n" | Where-Object { $_.Trim() } | ForEach-Object {
|
|
if ($_ -match "SCP ERROR|ERROR.*push|ERROR.*pull") {
|
|
Write-Host " $_" -ForegroundColor Red
|
|
} elseif ($_ -match "Pushed:|Pulled:") {
|
|
Write-Host " $_" -ForegroundColor Green
|
|
} else {
|
|
Write-Host " $_" -ForegroundColor Gray
|
|
}
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "[5] Error summary from this run" -ForegroundColor Yellow
|
|
Write-Host "=" * 80 -ForegroundColor Gray
|
|
|
|
$recentErrors = Get-Content $logFile -Tail 100 | Select-String -Pattern "SCP ERROR|ERROR.*push|ERROR.*pull"
|
|
|
|
if ($recentErrors) {
|
|
$errorCount = ($recentErrors | Measure-Object).Count
|
|
Write-Host "[FOUND] $errorCount error(s) in recent log:" -ForegroundColor Red
|
|
Write-Host ""
|
|
|
|
# Group similar errors
|
|
$errorGroups = $recentErrors | Group-Object {
|
|
if ($_ -match "SCP ERROR.*: (.+)") { $matches[1] }
|
|
else { $_ }
|
|
} | Sort-Object Count -Descending
|
|
|
|
foreach ($group in $errorGroups | Select-Object -First 5) {
|
|
Write-Host " [$($group.Count)x] $($group.Name)" -ForegroundColor Red
|
|
}
|
|
|
|
if ($errorGroups.Count -gt 5) {
|
|
Write-Host " ... and $($errorGroups.Count - 5) more error types" -ForegroundColor Yellow
|
|
}
|
|
} else {
|
|
Write-Host "[SUCCESS] No errors found in this sync run!" -ForegroundColor Green
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "=== Sync Trigger Complete ===" -ForegroundColor Cyan
|