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>
77 lines
2.7 KiB
PowerShell
77 lines
2.7 KiB
PowerShell
# Monitor AD2-to-NAS sync status periodically
|
|
|
|
param(
|
|
[int]$Checks = 5,
|
|
[int]$IntervalMinutes = 3
|
|
)
|
|
|
|
$Username = "INTRANET\sysadmin"
|
|
$Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
|
|
$Cred = New-Object System.Management.Automation.PSCredential($Username, $Password)
|
|
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "AD2-to-NAS Sync Monitor" -ForegroundColor Cyan
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "Checks: $Checks (every $IntervalMinutes minutes)"
|
|
Write-Host "Monitoring CRLF preservation on synced files"
|
|
Write-Host ""
|
|
|
|
for ($i = 1; $i -le $Checks; $i++) {
|
|
$Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
|
Write-Host "[$Timestamp] Check $i of $Checks" -ForegroundColor Yellow
|
|
Write-Host "----------------------------------------"
|
|
|
|
# Check AD2 sync log (last 10 lines)
|
|
try {
|
|
$LogTail = Invoke-Command -ComputerName 192.168.0.6 -Credential $Cred -ScriptBlock {
|
|
Get-Content 'C:\Shares\test\scripts\sync-from-nas.log' -Tail 10
|
|
}
|
|
|
|
Write-Host "[INFO] Recent sync log entries:"
|
|
$LogTail | ForEach-Object { Write-Host " $_" }
|
|
Write-Host ""
|
|
|
|
} catch {
|
|
Write-Host "[ERROR] Could not read AD2 sync log: $_" -ForegroundColor Red
|
|
Write-Host ""
|
|
}
|
|
|
|
# Check NAS file timestamps and CRLF
|
|
Write-Host "[INFO] Checking DEPLOY.BAT on NAS..."
|
|
$NASInfo = & 'C:\Windows\System32\OpenSSH\ssh.exe' -o BatchMode=yes root@192.168.0.9 'ls -la /data/test/DEPLOY.BAT' 2>&1
|
|
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Host " $NASInfo"
|
|
|
|
# Copy and verify CRLF
|
|
& 'C:\Windows\System32\OpenSSH\scp.exe' -O root@192.168.0.9:/data/test/DEPLOY.BAT ./DEPLOY_MONITOR.BAT 2>$null
|
|
|
|
if (Test-Path "DEPLOY_MONITOR.BAT") {
|
|
$Content = Get-Content "DEPLOY_MONITOR.BAT" -Raw
|
|
$Size = (Get-Item "DEPLOY_MONITOR.BAT").Length
|
|
|
|
if ($Content -match "`r`n") {
|
|
Write-Host " [SUCCESS] CRLF preserved ($Size bytes)" -ForegroundColor Green
|
|
} else {
|
|
Write-Host " [WARNING] LF only ($Size bytes)" -ForegroundColor Yellow
|
|
}
|
|
|
|
Remove-Item "DEPLOY_MONITOR.BAT" -Force
|
|
}
|
|
} else {
|
|
Write-Host " [ERROR] Could not access NAS" -ForegroundColor Red
|
|
}
|
|
|
|
Write-Host ""
|
|
|
|
if ($i -lt $Checks) {
|
|
Write-Host "Waiting $IntervalMinutes minutes until next check..."
|
|
Write-Host ""
|
|
Start-Sleep -Seconds ($IntervalMinutes * 60)
|
|
}
|
|
}
|
|
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "Monitoring Complete" -ForegroundColor Cyan
|
|
Write-Host "========================================" -ForegroundColor Cyan
|