Complete project organization: move all DOS files to projects/dataforth-dos, create client folders, update Claude config

This commit is contained in:
2026-01-20 16:02:58 -07:00
parent 2cb4cd1006
commit 4efceab2e3
87 changed files with 3653 additions and 111 deletions

View File

@@ -0,0 +1,69 @@
# Deploy all DOS BAT files to AD2 for distribution to DOS machines
$Username = "INTRANET\sysadmin"
$Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential($Username, $Password)
# Files to deploy
$BATFiles = @(
"UPDATE.BAT", # Machine backup utility
"NWTOC.BAT", # Network to Computer (pull updates)
"CTONW.BAT", # Computer to Network (push files)
"CHECKUPD.BAT", # Check for updates
"REBOOT.BAT", # Reboot utility
"DEPLOY.BAT" # One-time deployment installer
)
Write-Host "[INFO] Connecting to AD2..."
New-PSDrive -Name TEMP_AD2 -PSProvider FileSystem -Root "\\192.168.0.6\C$" -Credential $Cred -ErrorAction Stop | Out-Null
Write-Host "[INFO] Deploying BAT files to AD2..."
Write-Host ""
$TotalFiles = 0
$SuccessCount = 0
foreach ($File in $BATFiles) {
if (Test-Path $File) {
Write-Host " Processing: $File"
# Verify CRLF before copying
$Content = Get-Content $File -Raw
if ($Content -match "`r`n") {
Write-Host " [OK] CRLF verified"
# Copy to root (for DEPLOY.BAT and UPDATE.BAT access)
if ($File -in @("DEPLOY.BAT", "UPDATE.BAT")) {
Copy-Item $File "TEMP_AD2:\Shares\test\" -Force
Write-Host " [OK] Copied to root: C:\Shares\test\"
}
# Copy to COMMON\ProdSW (for all machines)
Copy-Item $File "TEMP_AD2:\Shares\test\COMMON\ProdSW\" -Force
Write-Host " [OK] Copied to COMMON\ProdSW\"
# Also copy to _COMMON\ProdSW (backup location)
Copy-Item $File "TEMP_AD2:\Shares\test\_COMMON\ProdSW\" -Force
Write-Host " [OK] Copied to _COMMON\ProdSW\"
$SuccessCount++
} else {
Write-Host " [ERROR] No CRLF found - skipping"
}
$TotalFiles++
Write-Host ""
} else {
Write-Host " [WARNING] $File not found - skipping"
Write-Host ""
}
}
Remove-PSDrive TEMP_AD2
Write-Host "[SUCCESS] Deployment complete"
Write-Host " Files processed: $TotalFiles"
Write-Host " Files deployed: $SuccessCount"
Write-Host ""
Write-Host "[INFO] Files will sync to NAS within 15 minutes"
Write-Host "[INFO] DOS machines can then run NWTOC to get updates"

View File

@@ -0,0 +1,34 @@
# Deploy all 4 fixed BAT files to AD2 via WinRM
$Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential("INTRANET\sysadmin", $Password)
Write-Host "[INFO] Connecting to AD2..." -ForegroundColor Cyan
$Session = New-PSSession -ComputerName 192.168.0.6 -Credential $Credential -ErrorAction Stop
Write-Host "[OK] Connected to AD2" -ForegroundColor Green
# Check/create directory on AD2
Write-Host "[INFO] Checking directory structure..." -ForegroundColor Cyan
Invoke-Command -Session $Session -ScriptBlock {
if (-not (Test-Path "C:\Shares\test\COMMON\ProdSW")) {
New-Item -Path "C:\Shares\test\COMMON\ProdSW" -ItemType Directory -Force | Out-Null
}
}
Write-Host "[INFO] Copying AUTOEXEC.BAT..." -ForegroundColor Cyan
Copy-Item "D:\ClaudeTools\AUTOEXEC.BAT" -Destination "C:\Shares\test\COMMON\ProdSW\" -ToSession $Session -ErrorAction Stop
Write-Host "[OK] AUTOEXEC.BAT deployed" -ForegroundColor Green
Write-Host "[INFO] Copying NWTOC.BAT..." -ForegroundColor Cyan
Copy-Item "D:\ClaudeTools\NWTOC.BAT" -Destination "C:\Shares\test\COMMON\ProdSW\" -ToSession $Session -ErrorAction Stop
Write-Host "[OK] NWTOC.BAT deployed" -ForegroundColor Green
Write-Host "[INFO] Copying CTONW.BAT..." -ForegroundColor Cyan
Copy-Item "D:\ClaudeTools\CTONW.BAT" -Destination "C:\Shares\test\COMMON\ProdSW\" -ToSession $Session -ErrorAction Stop
Write-Host "[OK] CTONW.BAT deployed" -ForegroundColor Green
Write-Host "[INFO] Copying DEPLOY.BAT..." -ForegroundColor Cyan
Copy-Item "D:\ClaudeTools\DEPLOY.BAT" -Destination "C:\Shares\test\COMMON\ProdSW\" -ToSession $Session -ErrorAction Stop
Write-Host "[OK] DEPLOY.BAT deployed" -ForegroundColor Green
Remove-PSSession $Session
Write-Host "[SUCCESS] All 4 files deployed to AD2:C:\Shares\test\COMMON\ProdSW\" -ForegroundColor Green

View File

@@ -0,0 +1,28 @@
# Deploy DEPLOY.BAT and UPDATE.BAT to AD2
# Files will be synced to NAS by AD2's Sync-FromNAS.ps1 script
$Username = "INTRANET\sysadmin"
$Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential($Username, $Password)
Write-Host "[INFO] Connecting to AD2..."
New-PSDrive -Name TEMP_AD2 -PSProvider FileSystem -Root "\\192.168.0.6\C$" -Credential $Cred -ErrorAction Stop | Out-Null
Write-Host "[INFO] Copying DEPLOY.BAT..."
Copy-Item DEPLOY.BAT TEMP_AD2:\Shares\test\ -Force
Write-Host "[INFO] Copying UPDATE.BAT..."
Copy-Item UPDATE.BAT TEMP_AD2:\Shares\test\ -Force
Write-Host "[INFO] Verifying line endings..."
$localDeploy = Get-Content DEPLOY.BAT -Raw
$adDeploy = Get-Content TEMP_AD2:\Shares\test\DEPLOY.BAT -Raw
if ($localDeploy -eq $adDeploy) {
Write-Host "[OK] Files copied successfully with CRLF line endings preserved"
} else {
Write-Host "[WARNING] File content may differ"
}
Remove-PSDrive TEMP_AD2
Write-Host "[SUCCESS] Deployment complete. Files will sync to NAS within 15 minutes."

View File

@@ -0,0 +1,55 @@
# Deploy BAT files directly to NAS with CRLF preservation
$BATFiles = @(
"DEPLOY.BAT",
"UPDATE.BAT",
"NWTOC.BAT",
"CTONW.BAT",
"CHECKUPD.BAT",
"REBOOT.BAT"
)
Write-Host "[INFO] Deploying BAT files directly to NAS..."
Write-Host "[INFO] Using SCP with -O flag (binary mode, preserves CRLF)"
Write-Host ""
$SuccessCount = 0
$TotalFiles = 0
foreach ($File in $BATFiles) {
if (Test-Path $File) {
Write-Host " Deploying: $File"
# Verify CRLF before sending
$Content = Get-Content $File -Raw
if ($Content -match "`r`n") {
$Size = (Get-Item $File).Length
Write-Host " Size: $Size bytes (with CRLF)"
# Copy to NAS root (/data/test/)
$result = & 'C:\Windows\System32\OpenSSH\scp.exe' -O $File root@192.168.0.9:/data/test/ 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host " [SUCCESS] Copied to /data/test/$File"
$SuccessCount++
} else {
Write-Host " [ERROR] Failed: $result"
}
} else {
Write-Host " [ERROR] No CRLF found - skipping"
}
$TotalFiles++
Write-Host ""
} else {
Write-Host " [WARNING] $File not found"
Write-Host ""
}
}
Write-Host "[COMPLETE] Direct deployment to NAS"
Write-Host " Files processed: $TotalFiles"
Write-Host " Files deployed: $SuccessCount"
Write-Host ""
Write-Host "[INFO] Files are now available at T:\ for DOS machines"
Write-Host "[INFO] Test DEPLOY.BAT on a DOS machine to verify CRLF"

View File

@@ -0,0 +1,58 @@
$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password)
Write-Host "================================================" -ForegroundColor Cyan
Write-Host "Deploying Correct BAT Files to AD2" -ForegroundColor Cyan
Write-Host "================================================" -ForegroundColor Cyan
Write-Host ""
# Map network drive
Write-Host "[1/4] Mapping network drive to AD2..." -ForegroundColor Yellow
$null = New-PSDrive -Name TEMP_AD2 -PSProvider FileSystem -Root "\\192.168.0.6\C$" -Credential $cred -ErrorAction Stop
Write-Host "[OK] Network drive mapped" -ForegroundColor Green
Write-Host ""
# Copy to _COMMON\ProdSW (update old versions)
Write-Host "[2/4] Updating _COMMON\ProdSW with correct versions..." -ForegroundColor Yellow
Copy-Item D:\ClaudeTools\DEPLOY.BAT "TEMP_AD2:\Shares\test\_COMMON\ProdSW\" -Force
Copy-Item D:\ClaudeTools\CTONW.BAT "TEMP_AD2:\Shares\test\_COMMON\ProdSW\" -Force
Copy-Item D:\ClaudeTools\CTONWTXT.BAT "TEMP_AD2:\Shares\test\_COMMON\ProdSW\" -Force
Copy-Item D:\ClaudeTools\NWTOC.BAT "TEMP_AD2:\Shares\test\_COMMON\ProdSW\" -Force
Copy-Item D:\ClaudeTools\UPDATE.BAT "TEMP_AD2:\Shares\test\_COMMON\ProdSW\" -Force
Copy-Item D:\ClaudeTools\CHECKUPD.BAT "TEMP_AD2:\Shares\test\_COMMON\ProdSW\" -Force
Copy-Item D:\ClaudeTools\STAGE.BAT "TEMP_AD2:\Shares\test\_COMMON\ProdSW\" -Force
Copy-Item D:\ClaudeTools\REBOOT.BAT "TEMP_AD2:\Shares\test\_COMMON\ProdSW\" -Force
Write-Host "[OK] _COMMON\ProdSW updated" -ForegroundColor Green
Write-Host ""
# Copy to COMMON\ProdSW (ensure latest)
Write-Host "[3/4] Ensuring COMMON\ProdSW has latest versions..." -ForegroundColor Yellow
Copy-Item D:\ClaudeTools\DEPLOY.BAT "TEMP_AD2:\Shares\test\COMMON\ProdSW\" -Force
Copy-Item D:\ClaudeTools\CTONW.BAT "TEMP_AD2:\Shares\test\COMMON\ProdSW\" -Force
Copy-Item D:\ClaudeTools\CTONWTXT.BAT "TEMP_AD2:\Shares\test\COMMON\ProdSW\" -Force
Copy-Item D:\ClaudeTools\NWTOC.BAT "TEMP_AD2:\Shares\test\COMMON\ProdSW\" -Force
Copy-Item D:\ClaudeTools\UPDATE.BAT "TEMP_AD2:\Shares\test\COMMON\ProdSW\" -Force
Copy-Item D:\ClaudeTools\CHECKUPD.BAT "TEMP_AD2:\Shares\test\COMMON\ProdSW\" -Force
Copy-Item D:\ClaudeTools\STAGE.BAT "TEMP_AD2:\Shares\test\COMMON\ProdSW\" -Force
Copy-Item D:\ClaudeTools\REBOOT.BAT "TEMP_AD2:\Shares\test\COMMON\ProdSW\" -Force
Write-Host "[OK] COMMON\ProdSW updated" -ForegroundColor Green
Write-Host ""
# Copy DEPLOY.BAT to root
Write-Host "[4/4] Copying DEPLOY.BAT to root (C:\Shares\test\)..." -ForegroundColor Yellow
Copy-Item D:\ClaudeTools\DEPLOY.BAT "TEMP_AD2:\Shares\test\" -Force
Write-Host "[OK] DEPLOY.BAT copied to root" -ForegroundColor Green
Write-Host ""
# Cleanup
Remove-PSDrive -Name TEMP_AD2
Write-Host "================================================" -ForegroundColor Green
Write-Host "Deployment Complete!" -ForegroundColor Green
Write-Host "================================================" -ForegroundColor Green
Write-Host ""
Write-Host "Files deployed to:" -ForegroundColor Cyan
Write-Host " - C:\Shares\test\COMMON\ProdSW\" -ForegroundColor White
Write-Host " - C:\Shares\test\_COMMON\ProdSW\" -ForegroundColor White
Write-Host " - C:\Shares\test\DEPLOY.BAT (root)" -ForegroundColor White
Write-Host ""

View File

@@ -0,0 +1,22 @@
# Deploy CTONW.BAT to AD2 via WinRM
$Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential("INTRANET\sysadmin", $Password)
Write-Host "[INFO] Connecting to AD2..." -ForegroundColor Cyan
$Session = New-PSSession -ComputerName 192.168.0.6 -Credential $Credential -ErrorAction Stop
Write-Host "[OK] Connected to AD2" -ForegroundColor Green
# Check/create directory on AD2
Write-Host "[INFO] Checking directory structure..." -ForegroundColor Cyan
Invoke-Command -Session $Session -ScriptBlock {
if (-not (Test-Path "C:\Shares\test\COMMON\ProdSW")) {
New-Item -Path "C:\Shares\test\COMMON\ProdSW" -ItemType Directory -Force | Out-Null
}
}
Write-Host "[INFO] Copying CTONW.BAT to C:\Shares\test\COMMON\ProdSW..." -ForegroundColor Cyan
Copy-Item "D:\ClaudeTools\CTONW.BAT" -Destination "C:\Shares\test\COMMON\ProdSW\" -ToSession $Session -ErrorAction Stop
Write-Host "[OK] CTONW.BAT deployed to AD2:C:\Shares\test\COMMON\ProdSW\" -ForegroundColor Green
Remove-PSSession $Session
Write-Host "[SUCCESS] Deployment complete" -ForegroundColor Green

View File

@@ -0,0 +1,107 @@
# Deploy Drive Test Fix - All BAT Files
# Removes unreliable DIR >nul pattern, uses direct IF NOT EXIST test
# Date: 2026-01-20
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Deploying Drive Test Fix" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# AD2 Connection Details
$AD2Host = "192.168.0.6"
$Username = "INTRANET\sysadmin"
$Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential($Username, $Password)
# Files to deploy with new versions
$Files = @(
@{Name="UPDATE.BAT"; Version="v2.2"; Changes="Simplified drive test"},
@{Name="NWTOC.BAT"; Version="v2.2"; Changes="Simplified drive test"},
@{Name="CTONW.BAT"; Version="v2.1"; Changes="Simplified drive test"},
@{Name="CHECKUPD.BAT"; Version="v1.2"; Changes="Simplified drive test"},
@{Name="DOSTEST.BAT"; Version="v1.1"; Changes="Fixed T: and X: drive tests"}
)
# Destinations
$Destinations = @(
"\\$AD2Host\C$\Shares\test\COMMON\ProdSW\",
"\\$AD2Host\C$\Shares\test\_COMMON\ProdSW\"
)
# Map network drive
Write-Host "Connecting to AD2..." -ForegroundColor Yellow
try {
New-PSDrive -Name TEMP_AD2 -PSProvider FileSystem -Root "\\$AD2Host\C$" -Credential $Cred -ErrorAction Stop | Out-Null
Write-Host "[OK] Connected to AD2" -ForegroundColor Green
Write-Host ""
} catch {
Write-Host "[ERROR] Failed to connect to AD2: $_" -ForegroundColor Red
exit 1
}
# Deploy to each destination
$TotalSuccess = 0
$TotalFiles = $Files.Count * $Destinations.Count
foreach ($Dest in $Destinations) {
$DestName = if ($Dest -like "*_COMMON*") { "_COMMON\ProdSW" } else { "COMMON\ProdSW" }
Write-Host "Deploying to $DestName..." -ForegroundColor Cyan
foreach ($File in $Files) {
$SourceFile = "D:\ClaudeTools\$($File.Name)"
$DestFile = "$Dest$($File.Name)"
if (-not (Test-Path $SourceFile)) {
Write-Host " [ERROR] Source not found: $($File.Name)" -ForegroundColor Red
continue
}
try {
Copy-Item -Path $SourceFile -Destination $DestFile -Force -ErrorAction Stop
Write-Host " [OK] $($File.Name) $($File.Version)" -ForegroundColor Green
$TotalSuccess++
} catch {
Write-Host " [ERROR] $($File.Name): $_" -ForegroundColor Red
}
}
Write-Host ""
}
# Cleanup
Remove-PSDrive -Name TEMP_AD2 -ErrorAction SilentlyContinue
# Summary
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Deployment Summary" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Issue Fixed:" -ForegroundColor Yellow
Write-Host " DIR T:\ >nul pattern was unreliable in DOS 6.22" -ForegroundColor White
Write-Host ""
Write-Host "Solution:" -ForegroundColor Yellow
Write-Host " Replaced with: IF NOT EXIST T:\*.* GOTO ERROR" -ForegroundColor White
Write-Host " Direct file existence test - most reliable for DOS 6.22" -ForegroundColor White
Write-Host ""
Write-Host "Files Updated:" -ForegroundColor Cyan
foreach ($File in $Files) {
Write-Host " $($File.Name) $($File.Version) - $($File.Changes)" -ForegroundColor Gray
}
Write-Host ""
Write-Host "Deployments: $TotalSuccess/$TotalFiles successful" -ForegroundColor $(if ($TotalSuccess -eq $TotalFiles) { "Green" } else { "Yellow" })
Write-Host ""
Write-Host "Pattern Changes:" -ForegroundColor Yellow
Write-Host " BEFORE (unreliable):" -ForegroundColor White
Write-Host " DIR T:\ >nul" -ForegroundColor Gray
Write-Host " IF ERRORLEVEL 1 GOTO NO_T_DRIVE" -ForegroundColor Gray
Write-Host " C:" -ForegroundColor Gray
Write-Host " IF NOT EXIST T:\*.* GOTO NO_T_DRIVE" -ForegroundColor Gray
Write-Host ""
Write-Host " AFTER (reliable):" -ForegroundColor White
Write-Host " REM DOS 6.22: Direct file test is most reliable" -ForegroundColor Gray
Write-Host " IF NOT EXIST T:\*.* GOTO NO_T_DRIVE" -ForegroundColor Gray
Write-Host ""
Write-Host "This should resolve drive detection issues!" -ForegroundColor Green
Write-Host ""
Write-Host "Next:" -ForegroundColor Yellow
Write-Host " AD2 will sync to NAS within 15 minutes" -ForegroundColor White
Write-Host " Test on TS-4R after sync completes" -ForegroundColor White

View File

@@ -0,0 +1,113 @@
# Deploy STARTNET.BAT path fix to AD2
# Fixes all references from C:\NET\STARTNET.BAT to C:\STARTNET.BAT
# Date: 2026-01-20
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Deploying STARTNET Path Fix" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# AD2 Connection Details
$AD2Host = "192.168.0.6"
$Username = "INTRANET\sysadmin"
$Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential($Username, $Password)
# Files to deploy
$Files = @(
@{Name="AUTOEXEC.BAT"; Dest="\\$AD2Host\C$\Shares\test\COMMON\ProdSW\AUTOEXEC.BAT"},
@{Name="DEPLOY.BAT"; Dest="\\$AD2Host\C$\Shares\test\COMMON\ProdSW\DEPLOY.BAT"},
@{Name="UPDATE.BAT"; Dest="\\$AD2Host\C$\Shares\test\COMMON\ProdSW\UPDATE.BAT"},
@{Name="CTONW.BAT"; Dest="\\$AD2Host\C$\Shares\test\COMMON\ProdSW\CTONW.BAT"},
@{Name="CHECKUPD.BAT"; Dest="\\$AD2Host\C$\Shares\test\COMMON\ProdSW\CHECKUPD.BAT"},
@{Name="NWTOC.BAT"; Dest="\\$AD2Host\C$\Shares\test\COMMON\ProdSW\NWTOC.BAT"},
@{Name="DOSTEST.BAT"; Dest="\\$AD2Host\C$\Shares\test\COMMON\ProdSW\DOSTEST.BAT"}
)
# Also deploy to _COMMON\ProdSW
$FilesAlt = @(
@{Name="AUTOEXEC.BAT"; Dest="\\$AD2Host\C$\Shares\test\_COMMON\ProdSW\AUTOEXEC.BAT"},
@{Name="DEPLOY.BAT"; Dest="\\$AD2Host\C$\Shares\test\_COMMON\ProdSW\DEPLOY.BAT"},
@{Name="UPDATE.BAT"; Dest="\\$AD2Host\C$\Shares\test\_COMMON\ProdSW\UPDATE.BAT"},
@{Name="CTONW.BAT"; Dest="\\$AD2Host\C$\Shares\test\_COMMON\ProdSW\CTONW.BAT"},
@{Name="CHECKUPD.BAT"; Dest="\\$AD2Host\C$\Shares\test\_COMMON\ProdSW\CHECKUPD.BAT"},
@{Name="NWTOC.BAT"; Dest="\\$AD2Host\C$\Shares\test\_COMMON\ProdSW\NWTOC.BAT"},
@{Name="DOSTEST.BAT"; Dest="\\$AD2Host\C$\Shares\test\_COMMON\ProdSW\DOSTEST.BAT"}
)
# Map network drive
Write-Host "Connecting to AD2..." -ForegroundColor Yellow
try {
New-PSDrive -Name TEMP_AD2 -PSProvider FileSystem -Root "\\$AD2Host\C$" -Credential $Cred -ErrorAction Stop | Out-Null
Write-Host "[OK] Connected to AD2" -ForegroundColor Green
Write-Host ""
} catch {
Write-Host "[ERROR] Failed to connect to AD2: $_" -ForegroundColor Red
exit 1
}
# Deploy to COMMON\ProdSW
Write-Host "Deploying to COMMON\ProdSW..." -ForegroundColor Cyan
$SuccessCount = 0
foreach ($File in $Files) {
$SourceFile = "D:\ClaudeTools\$($File.Name)"
if (-not (Test-Path $SourceFile)) {
Write-Host " [ERROR] Source not found: $($File.Name)" -ForegroundColor Red
continue
}
try {
Copy-Item -Path $SourceFile -Destination $File.Dest -Force -ErrorAction Stop
Write-Host " [OK] $($File.Name)" -ForegroundColor Green
$SuccessCount++
} catch {
Write-Host " [ERROR] $($File.Name): $_" -ForegroundColor Red
}
}
Write-Host ""
# Deploy to _COMMON\ProdSW
Write-Host "Deploying to _COMMON\ProdSW..." -ForegroundColor Cyan
foreach ($File in $FilesAlt) {
$SourceFile = "D:\ClaudeTools\$($File.Name)"
if (-not (Test-Path $SourceFile)) {
Write-Host " [ERROR] Source not found: $($File.Name)" -ForegroundColor Red
continue
}
try {
Copy-Item -Path $SourceFile -Destination $File.Dest -Force -ErrorAction Stop
Write-Host " [OK] $($File.Name)" -ForegroundColor Green
} catch {
Write-Host " [ERROR] $($File.Name): $_" -ForegroundColor Red
}
}
Write-Host ""
# Cleanup
Remove-PSDrive -Name TEMP_AD2 -ErrorAction SilentlyContinue
# Summary
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Deployment Complete" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Fixed Files Deployed: 7" -ForegroundColor White
Write-Host " - AUTOEXEC.BAT (C:\STARTNET.BAT reference)" -ForegroundColor Gray
Write-Host " - DEPLOY.BAT (C:\STARTNET.BAT reference)" -ForegroundColor Gray
Write-Host " - UPDATE.BAT (C:\STARTNET.BAT + XCOPY fix)" -ForegroundColor Gray
Write-Host " - CTONW.BAT (C:\STARTNET.BAT reference)" -ForegroundColor Gray
Write-Host " - CHECKUPD.BAT (C:\STARTNET.BAT reference)" -ForegroundColor Gray
Write-Host " - NWTOC.BAT (C:\STARTNET.BAT reference)" -ForegroundColor Gray
Write-Host " - DOSTEST.BAT (C:\STARTNET.BAT reference)" -ForegroundColor Gray
Write-Host ""
Write-Host "Changes:" -ForegroundColor Yellow
Write-Host " C:\NET\STARTNET.BAT -> C:\STARTNET.BAT" -ForegroundColor White
Write-Host ""
Write-Host "Next Steps:" -ForegroundColor Yellow
Write-Host "1. AD2 will sync to NAS within 15 minutes" -ForegroundColor White
Write-Host "2. Machines will get updates on next reboot or NWTOC run" -ForegroundColor White
Write-Host "3. Verify STARTNET.BAT exists at C:\STARTNET.BAT on machines" -ForegroundColor White
Write-Host ""

View File

@@ -0,0 +1,59 @@
# Deploy fixed BAT files to AD2 via WinRM
# This prevents sync from overwriting our DOS 6.22 fixes
$BATFiles = @(
"DEPLOY.BAT",
"UPDATE.BAT",
"NWTOC.BAT",
"CTONW.BAT",
"CHECKUPD.BAT",
"REBOOT.BAT",
"STAGE.BAT",
"DOSTEST.BAT",
"AUTOEXEC.BAT",
"STARTNET.BAT"
)
Write-Host "[INFO] Deploying fixed BAT files to AD2" -ForegroundColor Cyan
Write-Host ""
# Create credential
$Password = ConvertTo-SecureString "AZC0mpGuru!2024" -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential("guru", $Password)
# Create session
Write-Host "Connecting to AD2..." -ForegroundColor White
$Session = New-PSSession -ComputerName ad2 -Credential $Credential -ErrorAction Stop
Write-Host "[OK] Connected to AD2" -ForegroundColor Green
Write-Host ""
$TotalCopied = 0
foreach ($File in $BATFiles) {
$LocalPath = "D:\ClaudeTools\$File"
if (-not (Test-Path $LocalPath)) {
Write-Host "[SKIP] $File - not found locally" -ForegroundColor Yellow
continue
}
Write-Host "Copying: $File" -ForegroundColor White
try {
Copy-Item $LocalPath -Destination "C:\scripts\sync-copies\bat-files\" -ToSession $Session -ErrorAction Stop
Write-Host " [OK] Copied to AD2" -ForegroundColor Green
$TotalCopied++
} catch {
Write-Host " [ERROR] Failed: $_" -ForegroundColor Red
}
}
# Close session
Remove-PSSession $Session
Write-Host ""
Write-Host "[SUCCESS] Copied $TotalCopied files to AD2" -ForegroundColor Green
Write-Host ""
Write-Host "AD2 path: C:\scripts\sync-copies\bat-files\" -ForegroundColor Cyan
Write-Host "Next sync will deploy these fixed versions to NAS" -ForegroundColor Cyan
Write-Host ""

View File

@@ -0,0 +1,107 @@
# Deploy UPDATE.BAT v2.1 Fix to AD2
# Fixes "Invalid number of parameters" error in DOS 6.22 XCOPY
# Date: 2026-01-20
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Deploying UPDATE.BAT v2.1 to AD2" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# AD2 Connection Details
$AD2Host = "192.168.0.6"
$Username = "INTRANET\sysadmin"
$Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential($Username, $Password)
# Source file
$SourceFile = "D:\ClaudeTools\UPDATE.BAT"
# Destination paths (both COMMON and _COMMON)
$Destinations = @(
"\\$AD2Host\C$\Shares\test\COMMON\ProdSW\UPDATE.BAT",
"\\$AD2Host\C$\Shares\test\_COMMON\ProdSW\UPDATE.BAT",
"\\$AD2Host\C$\Shares\test\UPDATE.BAT" # Root level for easy access
)
# Verify source file exists
if (-not (Test-Path $SourceFile)) {
Write-Host "[ERROR] Source file not found: $SourceFile" -ForegroundColor Red
exit 1
}
Write-Host "[OK] Source file found: $SourceFile" -ForegroundColor Green
Write-Host ""
# Map network drive
Write-Host "Connecting to AD2..." -ForegroundColor Yellow
try {
New-PSDrive -Name TEMP_AD2 -PSProvider FileSystem -Root "\\$AD2Host\C$" -Credential $Cred -ErrorAction Stop | Out-Null
Write-Host "[OK] Connected to AD2" -ForegroundColor Green
Write-Host ""
} catch {
Write-Host "[ERROR] Failed to connect to AD2: $_" -ForegroundColor Red
exit 1
}
# Deploy to each destination
$SuccessCount = 0
foreach ($Dest in $Destinations) {
Write-Host "Deploying to: $Dest" -ForegroundColor Yellow
try {
# Create destination directory if it doesn't exist
$DestDir = Split-Path $Dest -Parent
if (-not (Test-Path $DestDir)) {
Write-Host " Creating directory: $DestDir" -ForegroundColor Yellow
New-Item -Path $DestDir -ItemType Directory -Force | Out-Null
}
# Copy file
Copy-Item -Path $SourceFile -Destination $Dest -Force -ErrorAction Stop
# Verify copy
if (Test-Path $Dest) {
Write-Host " [OK] Deployed successfully" -ForegroundColor Green
$SuccessCount++
} else {
Write-Host " [WARNING] File copied but verification failed" -ForegroundColor Yellow
}
} catch {
Write-Host " [ERROR] Failed: $_" -ForegroundColor Red
}
Write-Host ""
}
# Cleanup
Remove-PSDrive -Name TEMP_AD2 -ErrorAction SilentlyContinue
# Summary
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Deployment Summary" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Destinations: $($Destinations.Count)" -ForegroundColor White
Write-Host "Successful: $SuccessCount" -ForegroundColor Green
Write-Host "Failed: $($Destinations.Count - $SuccessCount)" -ForegroundColor $(if ($SuccessCount -eq $Destinations.Count) { "Green" } else { "Red" })
Write-Host ""
if ($SuccessCount -eq $Destinations.Count) {
Write-Host "[OK] UPDATE.BAT v2.1 deployed successfully!" -ForegroundColor Green
Write-Host ""
Write-Host "Next Steps:" -ForegroundColor Yellow
Write-Host "1. AD2 will sync to NAS within 15 minutes" -ForegroundColor White
Write-Host "2. Test on TS-4R machine:" -ForegroundColor White
Write-Host " T:" -ForegroundColor Gray
Write-Host " CD \COMMON\ProdSW" -ForegroundColor Gray
Write-Host " XCOPY UPDATE.BAT C:\BAT\ /Y" -ForegroundColor Gray
Write-Host " C:" -ForegroundColor Gray
Write-Host " CD \BAT" -ForegroundColor Gray
Write-Host " UPDATE" -ForegroundColor Gray
Write-Host ""
Write-Host "3. Verify backup completes without 'Invalid number of parameters' error" -ForegroundColor White
Write-Host "4. Check T:\TS-4R\BACKUP\ for copied files" -ForegroundColor White
} else {
Write-Host "[ERROR] Deployment incomplete - manual intervention required" -ForegroundColor Red
}
Write-Host ""
Write-Host "Changelog: UPDATE_BAT_FIX_2026-01-20.md" -ForegroundColor Cyan

View File

@@ -0,0 +1,93 @@
# Deploy XCOPY /D Fix - Round 2
# Fixes NWTOC.BAT and CHECKUPD.BAT XCOPY /D errors
# Date: 2026-01-20
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Deploying XCOPY /D Fix - Round 2" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# AD2 Connection Details
$AD2Host = "192.168.0.6"
$Username = "INTRANET\sysadmin"
$Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential($Username, $Password)
# Files to deploy
$Files = @(
@{Name="NWTOC.BAT"; Version="v2.1"},
@{Name="CHECKUPD.BAT"; Version="v1.1"}
)
# Destinations
$Destinations = @(
"\\$AD2Host\C$\Shares\test\COMMON\ProdSW\",
"\\$AD2Host\C$\Shares\test\_COMMON\ProdSW\"
)
# Map network drive
Write-Host "Connecting to AD2..." -ForegroundColor Yellow
try {
New-PSDrive -Name TEMP_AD2 -PSProvider FileSystem -Root "\\$AD2Host\C$" -Credential $Cred -ErrorAction Stop | Out-Null
Write-Host "[OK] Connected to AD2" -ForegroundColor Green
Write-Host ""
} catch {
Write-Host "[ERROR] Failed to connect to AD2: $_" -ForegroundColor Red
exit 1
}
# Deploy to each destination
$TotalSuccess = 0
foreach ($Dest in $Destinations) {
$DestName = if ($Dest -like "*_COMMON*") { "_COMMON\ProdSW" } else { "COMMON\ProdSW" }
Write-Host "Deploying to $DestName..." -ForegroundColor Cyan
foreach ($File in $Files) {
$SourceFile = "D:\ClaudeTools\$($File.Name)"
$DestFile = "$Dest$($File.Name)"
if (-not (Test-Path $SourceFile)) {
Write-Host " [ERROR] Source not found: $($File.Name)" -ForegroundColor Red
continue
}
try {
Copy-Item -Path $SourceFile -Destination $DestFile -Force -ErrorAction Stop
Write-Host " [OK] $($File.Name) $($File.Version)" -ForegroundColor Green
$TotalSuccess++
} catch {
Write-Host " [ERROR] $($File.Name): $_" -ForegroundColor Red
}
}
Write-Host ""
}
# Cleanup
Remove-PSDrive -Name TEMP_AD2 -ErrorAction SilentlyContinue
# Summary
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Deployment Summary" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Files Fixed:" -ForegroundColor White
Write-Host " NWTOC.BAT v2.1" -ForegroundColor Gray
Write-Host " - Line 88: Removed /D from XCOPY (ProdSW)" -ForegroundColor Gray
Write-Host " - Line 178: Removed /D from XCOPY (NET)" -ForegroundColor Gray
Write-Host ""
Write-Host " CHECKUPD.BAT v1.1" -ForegroundColor Gray
Write-Host " - Line 201: Removed /D from XCOPY" -ForegroundColor Gray
Write-Host " - Simplified file comparison logic" -ForegroundColor Gray
Write-Host ""
Write-Host "Deployments: $TotalSuccess/4 successful" -ForegroundColor $(if ($TotalSuccess -eq 4) { "Green" } else { "Yellow" })
Write-Host ""
Write-Host "Combined with previous fixes:" -ForegroundColor Yellow
Write-Host " UPDATE.BAT v2.1 - XCOPY /D fixed" -ForegroundColor White
Write-Host " NWTOC.BAT v2.1 - XCOPY /D fixed (2 instances)" -ForegroundColor White
Write-Host " CHECKUPD.BAT v1.1 - XCOPY /D fixed" -ForegroundColor White
Write-Host ""
Write-Host "All DOS 6.22 XCOPY /D errors now fixed!" -ForegroundColor Green
Write-Host ""
Write-Host "Next:" -ForegroundColor Yellow
Write-Host " AD2 will sync to NAS within 15 minutes" -ForegroundColor White
Write-Host " Test on TS-4R after sync completes" -ForegroundColor White

View File

@@ -0,0 +1,125 @@
# Fix DOS line endings on AD2 for Dataforth DOS system
Write-Host "=== Fixing DOS Files on AD2 (C:\Shares\test\) ===" -ForegroundColor Cyan
Write-Host ""
# Setup admin credentials for AD2
$password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("INTRANET\sysadmin", $password)
Write-Host "Connecting to AD2..." -ForegroundColor Yellow
Write-Host ""
try {
$result = Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
Write-Host "[INFO] Searching for .BAT files in C:\Shares\test\" -ForegroundColor Yellow
Write-Host ""
# Find all .BAT files in the test directory
$batFiles = Get-ChildItem -Path "C:\Shares\test" -Filter "*.BAT" -Recurse -ErrorAction SilentlyContinue
Write-Host "Found $($batFiles.Count) batch files" -ForegroundColor Cyan
Write-Host ""
$needsConversion = @()
$results = @()
foreach ($file in $batFiles) {
try {
$bytes = [System.IO.File]::ReadAllBytes($file.FullName)
$hasCRLF = $false
$hasLF = $false
for ($i = 0; $i -lt $bytes.Length - 1; $i++) {
if ($bytes[$i] -eq 13 -and $bytes[$i+1] -eq 10) {
$hasCRLF = $true
break
}
if ($bytes[$i] -eq 10 -and ($i -eq 0 -or $bytes[$i-1] -ne 13)) {
$hasLF = $true
break
}
}
$relativePath = $file.FullName.Replace("C:\Shares\test\", "")
if ($hasCRLF) {
$status = "OK"
$format = "CRLF (DOS)"
} elseif ($hasLF) {
$status = "NEEDS CONVERSION"
$format = "LF (Unix)"
$needsConversion += $file
} else {
$status = "EMPTY/SINGLE LINE"
$format = "No line endings"
}
$results += [PSCustomObject]@{
File = $relativePath
Status = $status
Format = $format
}
Write-Host "[$status] $relativePath" -ForegroundColor $(if ($status -eq "OK") { "Green" } elseif ($status -eq "NEEDS CONVERSION") { "Red" } else { "Yellow" })
Write-Host " $format" -ForegroundColor Gray
Write-Host ""
} catch {
Write-Host "[ERROR] $($file.Name): $($_.Exception.Message)" -ForegroundColor Red
}
}
# Convert files that need it
if ($needsConversion.Count -gt 0) {
Write-Host "=== Converting $($needsConversion.Count) files to DOS format ===" -ForegroundColor Yellow
Write-Host ""
$converted = 0
$errors = 0
foreach ($file in $needsConversion) {
try {
# Read content
$content = Get-Content $file.FullName -Raw
# Convert to DOS format (CRLF)
$dosContent = $content -replace "`r?`n", "`r`n"
# Write back as ASCII (DOS compatible)
[System.IO.File]::WriteAllText($file.FullName, $dosContent, [System.Text.Encoding]::ASCII)
Write-Host "[OK] $($file.Name)" -ForegroundColor Green
$converted++
} catch {
Write-Host "[ERROR] $($file.Name): $($_.Exception.Message)" -ForegroundColor Red
$errors++
}
}
Write-Host ""
Write-Host "=== Conversion Complete ===" -ForegroundColor Green
Write-Host "Converted: $converted files" -ForegroundColor Green
if ($errors -gt 0) {
Write-Host "Errors: $errors files" -ForegroundColor Red
}
} else {
Write-Host "=== All Files OK ===" -ForegroundColor Green
Write-Host "All batch files already have proper DOS (CRLF) line endings." -ForegroundColor Green
}
# Return summary
return @{
TotalFiles = $batFiles.Count
Converted = $needsConversion.Count
Results = $results
}
}
Write-Host ""
Write-Host "=== Summary ===" -ForegroundColor Cyan
Write-Host "Total batch files found: $($result.TotalFiles)" -ForegroundColor White
Write-Host "Files converted: $($result.Converted)" -ForegroundColor $(if ($result.Converted -gt 0) { "Yellow" } else { "Green" })
} catch {
Write-Host "[ERROR] Failed to connect to AD2" -ForegroundColor Red
Write-Host $_.Exception.Message -ForegroundColor Red
}

View File

@@ -0,0 +1,75 @@
# Simple version - fix specific DOS files on AD2
Write-Host "=== Fixing DOS Files on AD2 ===" -ForegroundColor Cyan
Write-Host ""
# Setup admin credentials
$password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("INTRANET\sysadmin", $password)
# Known batch file locations on AD2
$filesToCheck = @(
"C:\Shares\test\COMMON\ProdSW\DEPLOY.BAT",
"C:\Shares\test\COMMON\ProdSW\NWTOC.BAT",
"C:\Shares\test\COMMON\ProdSW\CTONW.BAT",
"C:\Shares\test\COMMON\ProdSW\UPDATE.BAT",
"C:\Shares\test\COMMON\ProdSW\STAGE.BAT",
"C:\Shares\test\COMMON\ProdSW\CHECKUPD.BAT",
"C:\Shares\test\COMMON\DOS\AUTOEXEC.NEW",
"C:\Shares\test\UPDATE.BAT"
)
Write-Host "Checking and converting DOS batch files on AD2..." -ForegroundColor Yellow
Write-Host ""
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
param($files)
$converted = 0
$alreadyOK = 0
$notFound = 0
foreach ($filePath in $files) {
$fileName = Split-Path $filePath -Leaf
if (-not (Test-Path $filePath)) {
Write-Host "[SKIP] $fileName - Not found" -ForegroundColor Yellow
$notFound++
continue
}
try {
# Check current line endings
$bytes = [System.IO.File]::ReadAllBytes($filePath)
$hasCRLF = $false
for ($i = 0; $i -lt ($bytes.Length - 1); $i++) {
if ($bytes[$i] -eq 13 -and $bytes[$i+1] -eq 10) {
$hasCRLF = $true
break
}
}
if ($hasCRLF) {
Write-Host "[OK] $fileName - Already DOS format (CRLF)" -ForegroundColor Green
$alreadyOK++
} else {
# Convert to DOS format
$content = Get-Content $filePath -Raw
$dosContent = $content -replace "`r?`n", "`r`n"
[System.IO.File]::WriteAllText($filePath, $dosContent, [System.Text.Encoding]::ASCII)
Write-Host "[CONV] $fileName - Converted to DOS format" -ForegroundColor Cyan
$converted++
}
} catch {
Write-Host "[ERROR] $fileName - $($_.Exception.Message)" -ForegroundColor Red
}
}
Write-Host ""
Write-Host "=== Summary ===" -ForegroundColor Cyan
Write-Host "Already OK: $alreadyOK" -ForegroundColor Green
Write-Host "Converted: $converted" -ForegroundColor Cyan
Write-Host "Not Found: $notFound" -ForegroundColor Yellow
} -ArgumentList (,$filesToCheck)

View File

@@ -0,0 +1,47 @@
# Fix AD2 Sync-FromNAS.ps1 to preserve CRLF line endings
# Add -O flag to SCP commands to use legacy protocol (binary mode)
$Username = "INTRANET\sysadmin"
$Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential($Username, $Password)
Write-Host "[INFO] Connecting to AD2..."
# Read the current script
$ScriptContent = Invoke-Command -ComputerName 192.168.0.6 -Credential $Cred -ScriptBlock {
Get-Content 'C:\Shares\test\scripts\Sync-FromNAS.ps1' -Raw
}
Write-Host "[INFO] Current script retrieved"
# Create backup
$BackupName = "Sync-FromNAS_backup_$(Get-Date -Format 'yyyyMMdd_HHmmss').ps1"
Invoke-Command -ComputerName 192.168.0.6 -Credential $Cred -ScriptBlock {
param($Content, $Backup)
Set-Content "C:\Shares\test\scripts\$Backup" -Value $Content
} -ArgumentList $ScriptContent, $BackupName
Write-Host "[OK] Backup created: $BackupName"
# Fix the script - Add -O flag to SCP commands
$FixedContent = $ScriptContent -replace '& \$SCP -o StrictHostKeyChecking', '& $SCP -O -o StrictHostKeyChecking'
# Count changes
$Changes = ([regex]::Matches($FixedContent, '-O -o')).Count
Write-Host "[INFO] Adding -O flag to $Changes SCP commands"
# Upload fixed script
Invoke-Command -ComputerName 192.168.0.6 -Credential $Cred -ScriptBlock {
param($Content)
Set-Content 'C:\Shares\test\scripts\Sync-FromNAS.ps1' -Value $Content
} -ArgumentList $FixedContent
Write-Host "[SUCCESS] Sync-FromNAS.ps1 updated on AD2"
Write-Host ""
Write-Host "[INFO] The -O flag forces legacy SCP protocol (binary mode)"
Write-Host "[INFO] This prevents line ending conversion (CRLF preserved)"
Write-Host ""
Write-Host "Next steps:"
Write-Host " 1. Redeploy DEPLOY.BAT and UPDATE.BAT to AD2"
Write-Host " 2. Wait for next sync cycle (runs every 15 minutes)"
Write-Host " 3. Verify CRLF preserved on NAS"

View File

@@ -0,0 +1,60 @@
$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password)
Write-Host "================================================" -ForegroundColor Cyan
Write-Host "Creating Junction: COMMON -> _COMMON" -ForegroundColor Cyan
Write-Host "================================================" -ForegroundColor Cyan
Write-Host ""
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
Write-Host "[1/4] Backing up COMMON to COMMON.backup..." -ForegroundColor Yellow
if (Test-Path "C:\Shares\test\COMMON.backup") {
Remove-Item "C:\Shares\test\COMMON.backup" -Recurse -Force
}
Copy-Item "C:\Shares\test\COMMON" "C:\Shares\test\COMMON.backup" -Recurse -Force
Write-Host "[OK] Backup created" -ForegroundColor Green
Write-Host ""
Write-Host "[2/4] Copying AUTOEXEC.BAT from COMMON to _COMMON..." -ForegroundColor Yellow
Copy-Item "C:\Shares\test\COMMON\ProdSW\AUTOEXEC.BAT" "C:\Shares\test\_COMMON\ProdSW\" -Force
Write-Host "[OK] AUTOEXEC.BAT copied to _COMMON" -ForegroundColor Green
Write-Host ""
Write-Host "[3/4] Removing COMMON directory..." -ForegroundColor Yellow
Remove-Item "C:\Shares\test\COMMON" -Recurse -Force
Write-Host "[OK] COMMON removed" -ForegroundColor Green
Write-Host ""
Write-Host "[4/4] Creating junction COMMON -> _COMMON..." -ForegroundColor Yellow
cmd /c mklink /J "C:\Shares\test\COMMON" "C:\Shares\test\_COMMON"
Write-Host "[OK] Junction created" -ForegroundColor Green
Write-Host ""
Write-Host "=== Verification ===" -ForegroundColor Yellow
$junction = Get-Item "C:\Shares\test\COMMON" -Force
Write-Host "COMMON LinkType: $($junction.LinkType)" -ForegroundColor Cyan
Write-Host "COMMON Target: $($junction.Target)" -ForegroundColor Cyan
Write-Host ""
Write-Host "=== File count check ===" -ForegroundColor Yellow
$underCount = (Get-ChildItem "C:\Shares\test\_COMMON\ProdSW" -File | Measure-Object).Count
$commonCount = (Get-ChildItem "C:\Shares\test\COMMON\ProdSW" -File | Measure-Object).Count
Write-Host "_COMMON\ProdSW: $underCount files" -ForegroundColor White
Write-Host "COMMON\ProdSW: $commonCount files (via junction)" -ForegroundColor White
if ($underCount -eq $commonCount) {
Write-Host "[OK] File counts match!" -ForegroundColor Green
} else {
Write-Host "[ERROR] File counts differ!" -ForegroundColor Red
}
}
Write-Host ""
Write-Host "================================================" -ForegroundColor Green
Write-Host "Junction Created Successfully!" -ForegroundColor Green
Write-Host "================================================" -ForegroundColor Green
Write-Host ""
Write-Host "Result:" -ForegroundColor Cyan
Write-Host " COMMON is now a junction pointing to _COMMON" -ForegroundColor White
Write-Host " Both paths access the same files" -ForegroundColor White
Write-Host " Backup saved to: C:\Shares\test\COMMON.backup" -ForegroundColor White

View File

@@ -0,0 +1,98 @@
# Fix Copy-ToNAS to always log detailed SCP results
$password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("INTRANET\sysadmin", $password)
Write-Host "=== Fixing Copy-ToNAS Error Logging ===" -ForegroundColor Cyan
Write-Host ""
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
$scriptPath = "C:\Shares\test\scripts\Sync-FromNAS.ps1"
Write-Host "[1] Creating backup" -ForegroundColor Yellow
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
Copy-Item $scriptPath "$scriptPath.backup-$timestamp"
Write-Host "[OK] Backup: Sync-FromNAS.ps1.backup-$timestamp" -ForegroundColor Green
Write-Host ""
Write-Host "[2] Updating Copy-ToNAS function" -ForegroundColor Yellow
$content = Get-Content $scriptPath
# Find and replace the Copy-ToNAS function
$newFunction = @'
function Copy-ToNAS {
param(
[string]$LocalPath,
[string]$RemotePath
)
# Ensure remote directory exists
$remoteDir = Split-Path -Parent $RemotePath
Invoke-NASCommand "mkdir -p '$remoteDir'" | Out-Null
$result = & $SCP -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile="C:\Shares\test\scripts\.ssh\known_hosts" -o PreferredAuthentications=password -o PubkeyAuthentication=no -o PasswordAuthentication=yes $LocalPath "${NAS_USER}@${NAS_IP}:$RemotePath" 2>&1
$exitCode = $LASTEXITCODE
if ($exitCode -ne 0) {
# Log detailed error
$errorMsg = $result | Out-String
Write-Log " SCP PUSH ERROR (exit $exitCode): $errorMsg"
}
return $exitCode -eq 0
}
'@
# Find the function start
$funcStart = -1
$funcEnd = -1
$braceCount = 0
for ($i = 0; $i -lt $content.Count; $i++) {
if ($content[$i] -match '^function Copy-ToNAS') {
$funcStart = $i
continue
}
if ($funcStart -ge 0) {
if ($content[$i] -match '\{') { $braceCount++ }
if ($content[$i] -match '\}') {
$braceCount--
if ($braceCount -eq 0) {
$funcEnd = $i
break
}
}
}
}
if ($funcStart -ge 0 -and $funcEnd -gt $funcStart) {
Write-Host "[FOUND] Copy-ToNAS function at lines $($funcStart+1)-$($funcEnd+1)" -ForegroundColor Cyan
# Replace the function
$newContent = @()
$newContent += $content[0..($funcStart-1)]
$newContent += $newFunction
$newContent += $content[($funcEnd+1)..($content.Count-1)]
$newContent | Out-File -FilePath $scriptPath -Encoding UTF8 -Force
Write-Host "[OK] Function updated with enhanced error logging" -ForegroundColor Green
} else {
Write-Host "[ERROR] Could not find Copy-ToNAS function boundaries" -ForegroundColor Red
}
Write-Host ""
Write-Host "[3] Verifying update" -ForegroundColor Yellow
$updatedContent = Get-Content $scriptPath -Raw
if ($updatedContent -match 'SCP PUSH ERROR.*exit.*exitCode') {
Write-Host "[SUCCESS] Enhanced error logging is in place" -ForegroundColor Green
} else {
Write-Host "[WARNING] Could not verify error logging" -ForegroundColor Yellow
}
}
Write-Host ""
Write-Host "=== Fix Complete ===" -ForegroundColor Cyan

View File

@@ -0,0 +1,48 @@
# Create DOS directory and push system files
$password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("INTRANET\sysadmin", $password)
Write-Host "=== Fixing DOS System Files ===" -ForegroundColor Cyan
Write-Host ""
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
param($autoexecContent, $startnetContent)
Write-Host "[1] Checking directory structure" -ForegroundColor Yellow
# Check if COMMON\DOS exists, create if not
$dosDir = "C:\Shares\test\COMMON\DOS"
if (-not (Test-Path $dosDir)) {
Write-Host "[INFO] Creating directory: $dosDir" -ForegroundColor Cyan
New-Item -Path $dosDir -ItemType Directory -Force | Out-Null
Write-Host "[OK] Directory created" -ForegroundColor Green
} else {
Write-Host "[OK] Directory exists: $dosDir" -ForegroundColor Green
}
Write-Host ""
Write-Host "[2] Copying AUTOEXEC.BAT" -ForegroundColor Yellow
$autoexecPath = Join-Path $dosDir "AUTOEXEC.BAT"
$autoexecContent | Out-File -FilePath $autoexecPath -Encoding ASCII -Force
Write-Host "[OK] Copied to: $autoexecPath" -ForegroundColor Green
Write-Host ""
Write-Host "[3] Copying STARTNET.BAT" -ForegroundColor Yellow
$startnetPath = Join-Path $dosDir "STARTNET.BAT"
$startnetContent | Out-File -FilePath $startnetPath -Encoding ASCII -Force
Write-Host "[OK] Copied to: $startnetPath" -ForegroundColor Green
Write-Host ""
Write-Host "[4] Listing files in COMMON\DOS" -ForegroundColor Yellow
Get-ChildItem $dosDir | ForEach-Object {
Write-Host " $($_.Name)" -ForegroundColor Gray
}
} -ArgumentList (Get-Content "D:\ClaudeTools\AUTOEXEC.BAT" -Raw), (Get-Content "D:\ClaudeTools\STARTNET.BAT" -Raw)
Write-Host ""
Write-Host "=== Complete ===" -ForegroundColor Cyan
Write-Host "[INFO] All 10 fixed BAT files now on AD2" -ForegroundColor Green
Write-Host "[INFO] Next sync will push to NAS (/data/test/)" -ForegroundColor Cyan
Write-Host "[INFO] DOS machines can access at T:\ drive" -ForegroundColor Cyan

View File

@@ -0,0 +1,97 @@
# Fix multi-line IF blocks with parentheses - not supported in DOS 6.22
# Convert to single-line IF statements with GOTO labels
$BATFiles = @(
"DEPLOY.BAT",
"DEPLOY_VERIFY.BAT",
"DEPLOY_TEST.BAT",
"DEPLOY_FROM_NAS.BAT",
"DEPLOY_FROM_AD2.BAT"
)
Write-Host "[INFO] Fixing multi-line IF blocks (not in DOS 6.22)" -ForegroundColor Cyan
Write-Host ""
foreach ($File in $BATFiles) {
$FilePath = "D:\ClaudeTools\$File"
if (-not (Test-Path $FilePath)) {
Write-Host "[SKIP] $File - not found" -ForegroundColor Yellow
continue
}
Write-Host "Processing: $File" -ForegroundColor White
$Content = Get-Content $FilePath -Raw
# Fix 1: AUTOEXEC.BAT backup block (lines 164-171)
# Convert multi-line IF ( ... ) ELSE ( ... ) to single-line IF with GOTO
$OldBlock1 = @'
REM Backup current AUTOEXEC.BAT
IF EXIST C:\AUTOEXEC.BAT (
ECHO Backing up AUTOEXEC.BAT...
COPY C:\AUTOEXEC.BAT C:\AUTOEXEC.SAV >NUL
IF ERRORLEVEL 1 GOTO BACKUP_ERROR
ECHO [OK] Backup created: C:\AUTOEXEC.SAV
) ELSE (
ECHO [WARNING] No existing AUTOEXEC.BAT found
)
ECHO.
'@
$NewBlock1 = @'
REM Backup current AUTOEXEC.BAT
IF NOT EXIST C:\AUTOEXEC.BAT GOTO NO_AUTOEXEC_BACKUP
ECHO Backing up AUTOEXEC.BAT...
COPY C:\AUTOEXEC.BAT C:\AUTOEXEC.SAV >NUL
IF ERRORLEVEL 1 GOTO BACKUP_ERROR
ECHO [OK] Backup created: C:\AUTOEXEC.SAV
GOTO AUTOEXEC_BACKUP_DONE
:NO_AUTOEXEC_BACKUP
ECHO [WARNING] No existing AUTOEXEC.BAT found
:AUTOEXEC_BACKUP_DONE
ECHO.
'@
# Fix 2: MACHINE variable check block (lines 244-247)
# Convert multi-line IF ( ... ) to single-line IF with GOTO
$OldBlock2 = @'
REM Check if MACHINE variable already exists in AUTOEXEC.BAT
IF EXIST C:\AUTOEXEC.BAT (
FIND "SET MACHINE=" C:\AUTOEXEC.BAT >NUL
IF NOT ERRORLEVEL 1 GOTO MACHINE_EXISTS
)
'@
$NewBlock2 = @'
REM Check if MACHINE variable already exists in AUTOEXEC.BAT
IF NOT EXIST C:\AUTOEXEC.BAT GOTO ADD_MACHINE_VAR
FIND "SET MACHINE=" C:\AUTOEXEC.BAT >NUL
IF NOT ERRORLEVEL 1 GOTO MACHINE_EXISTS
:ADD_MACHINE_VAR
'@
$Content = $Content -replace [regex]::Escape($OldBlock1), $NewBlock1
$Content = $Content -replace [regex]::Escape($OldBlock2), $NewBlock2
Set-Content $FilePath $Content -NoNewline
Write-Host " [OK] Fixed multi-line IF blocks" -ForegroundColor Green
}
Write-Host ""
Write-Host "[SUCCESS] All IF blocks converted to DOS 6.22 syntax" -ForegroundColor Green
Write-Host ""
Write-Host "DOS 6.22 IF syntax:" -ForegroundColor Cyan
Write-Host " IF condition command (single line only)" -ForegroundColor White
Write-Host " IF condition GOTO label (for multi-step logic)" -ForegroundColor White
Write-Host ""
Write-Host " NOT SUPPORTED:" -ForegroundColor Red
Write-Host " IF condition ( ... ) (parentheses)" -ForegroundColor Red
Write-Host " IF condition ... ELSE ... (ELSE clause)" -ForegroundColor Red
Write-Host ""

View File

@@ -0,0 +1,93 @@
# Fix the known_hosts path issue in Sync-FromNAS.ps1
$password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("INTRANET\sysadmin", $password)
Write-Host "=== Fixing Known Hosts Path ===" -ForegroundColor Cyan
Write-Host ""
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
$scriptPath = "C:\Shares\test\scripts\Sync-FromNAS.ps1"
Write-Host "[1] Creating backup" -ForegroundColor Yellow
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
Copy-Item $scriptPath "$scriptPath.backup-$timestamp"
Write-Host "[OK] Backup created: Sync-FromNAS.ps1.backup-$timestamp" -ForegroundColor Green
Write-Host ""
Write-Host "[2] Ensuring .ssh directory exists" -ForegroundColor Yellow
$sshDir = "C:\Shares\test\scripts\.ssh"
if (-not (Test-Path $sshDir)) {
New-Item -Path $sshDir -ItemType Directory -Force | Out-Null
Write-Host "[OK] Created: $sshDir" -ForegroundColor Green
} else {
Write-Host "[OK] Directory exists: $sshDir" -ForegroundColor Green
}
Write-Host ""
Write-Host "[3] Updating SCP commands with absolute path" -ForegroundColor Yellow
$content = Get-Content $scriptPath
$updated = $false
for ($i = 0; $i -lt $content.Count; $i++) {
# Look for SCP commands with UserKnownHostsFile parameter
if ($content[$i] -match 'UserKnownHostsFile="\$SCRIPTS_DIR\\.ssh\\known_hosts"') {
# Replace with absolute path
$content[$i] = $content[$i] -replace 'UserKnownHostsFile="\$SCRIPTS_DIR\\.ssh\\known_hosts"', 'UserKnownHostsFile="C:\Shares\test\scripts\.ssh\known_hosts"'
Write-Host "[UPDATED] Line $($i+1): Changed to absolute path" -ForegroundColor Green
$updated = $true
}
}
if ($updated) {
$content | Out-File -FilePath $scriptPath -Encoding UTF8 -Force
Write-Host "[OK] Script updated with absolute path" -ForegroundColor Green
} else {
Write-Host "[INFO] No changes needed - path already absolute" -ForegroundColor Yellow
}
Write-Host ""
Write-Host "[4] Creating initial known_hosts file" -ForegroundColor Yellow
$knownHostsPath = "C:\Shares\test\scripts\.ssh\known_hosts"
# Get NAS host key if not already present
if (-not (Test-Path $knownHostsPath)) {
Write-Host "[INFO] Creating new known_hosts file" -ForegroundColor Cyan
# Create empty file - StrictHostKeyChecking=accept-new will add keys automatically
New-Item -Path $knownHostsPath -ItemType File -Force | Out-Null
Write-Host "[OK] Created: $knownHostsPath" -ForegroundColor Green
} else {
$keyCount = (Get-Content $knownHostsPath | Measure-Object -Line).Lines
Write-Host "[OK] Exists with $keyCount host key(s)" -ForegroundColor Green
}
Write-Host ""
Write-Host "[5] Testing SCP with fixed path" -ForegroundColor Yellow
Write-Host "=== Testing a single file transfer ===" -ForegroundColor Gray
# Create a test file
$testFile = "C:\Shares\test\scripts\scp-test-$(Get-Date -Format 'yyyyMMddHHmmss').txt"
"SCP Test from AD2 at $(Get-Date)" | Out-File $testFile
$result = & "C:\Program Files\OpenSSH\scp.exe" -v `
-o StrictHostKeyChecking=accept-new `
-o UserKnownHostsFile="C:\Shares\test\scripts\.ssh\known_hosts" `
-o PreferredAuthentications=password `
-o PubkeyAuthentication=no `
-o PasswordAuthentication=yes `
$testFile "admin@192.168.0.9:/volume1/test/scp-test.txt" 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "[SUCCESS] SCP test transfer completed!" -ForegroundColor Green
Write-Host "[OK] Host key added to known_hosts" -ForegroundColor Green
Remove-Item $testFile -Force
} else {
Write-Host "[ERROR] SCP test failed (exit code: $LASTEXITCODE)" -ForegroundColor Red
Write-Host "Output:" -ForegroundColor Yellow
$result | ForEach-Object { Write-Host " $_" -ForegroundColor Gray }
}
}
Write-Host ""
Write-Host "=== Fix Complete ===" -ForegroundColor Cyan

View File

@@ -0,0 +1,77 @@
# Fix the known_hosts path issue in Sync-FromNAS.ps1 (no interactive test)
$password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("INTRANET\sysadmin", $password)
Write-Host "=== Fixing Known Hosts Path ===" -ForegroundColor Cyan
Write-Host ""
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
$scriptPath = "C:\Shares\test\scripts\Sync-FromNAS.ps1"
Write-Host "[1] Creating backup" -ForegroundColor Yellow
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
Copy-Item $scriptPath "$scriptPath.backup-$timestamp"
Write-Host "[OK] Backup created: Sync-FromNAS.ps1.backup-$timestamp" -ForegroundColor Green
Write-Host ""
Write-Host "[2] Updating SCP commands with absolute path" -ForegroundColor Yellow
$content = Get-Content $scriptPath
$updated = $false
for ($i = 0; $i -lt $content.Count; $i++) {
# Look for SCP commands with UserKnownHostsFile parameter
if ($content[$i] -match 'UserKnownHostsFile="\$SCRIPTS_DIR\\.ssh\\known_hosts"') {
# Replace with absolute path
$content[$i] = $content[$i] -replace 'UserKnownHostsFile="\$SCRIPTS_DIR\\.ssh\\known_hosts"', 'UserKnownHostsFile="C:\Shares\test\scripts\.ssh\known_hosts"'
Write-Host "[UPDATED] Line $($i+1): Changed to absolute path" -ForegroundColor Green
$updated = $true
}
}
if ($updated) {
$content | Out-File -FilePath $scriptPath -Encoding UTF8 -Force
Write-Host "[OK] Script updated successfully" -ForegroundColor Green
} else {
Write-Host "[INFO] No changes needed - path already absolute" -ForegroundColor Yellow
}
Write-Host ""
Write-Host "[3] Ensuring .ssh directory exists" -ForegroundColor Yellow
$sshDir = "C:\Shares\test\scripts\.ssh"
if (-not (Test-Path $sshDir)) {
New-Item -Path $sshDir -ItemType Directory -Force | Out-Null
Write-Host "[OK] Created: $sshDir" -ForegroundColor Green
} else {
Write-Host "[OK] Directory exists: $sshDir" -ForegroundColor Green
}
Write-Host ""
Write-Host "[4] Checking known_hosts file" -ForegroundColor Yellow
$knownHostsPath = "C:\Shares\test\scripts\.ssh\known_hosts"
if (Test-Path $knownHostsPath) {
$keyCount = (Get-Content $knownHostsPath | Measure-Object -Line).Lines
Write-Host "[OK] Exists with $keyCount host key(s)" -ForegroundColor Green
} else {
# Create empty file - StrictHostKeyChecking=accept-new will add keys on first connection
New-Item -Path $knownHostsPath -ItemType File -Force | Out-Null
Write-Host "[OK] Created empty known_hosts file" -ForegroundColor Green
}
Write-Host ""
Write-Host "[5] Verification - checking updated script" -ForegroundColor Yellow
$updatedContent = Get-Content $scriptPath -Raw
if ($updatedContent -match 'UserKnownHostsFile="C:\\Shares\\test\\scripts\\.ssh\\known_hosts"') {
Write-Host "[SUCCESS] Absolute path is now in the script" -ForegroundColor Green
} else {
Write-Host "[WARNING] Could not verify path update" -ForegroundColor Yellow
}
}
Write-Host ""
Write-Host "=== Fix Complete ===" -ForegroundColor Cyan
Write-Host ""
Write-Host "The sync script will automatically accept the NAS host key" -ForegroundColor Cyan
Write-Host "on the next run (every 15 minutes via scheduled task)." -ForegroundColor Cyan

View File

@@ -0,0 +1,67 @@
# Fix the missing line break on line 92
$password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("INTRANET\sysadmin", $password)
Write-Host "=== Fixing Line Break Issue ===" -ForegroundColor Cyan
Write-Host ""
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
$scriptPath = "C:\Shares\test\scripts\Sync-FromNAS.ps1"
Write-Host "[1] Creating backup" -ForegroundColor Yellow
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
Copy-Item $scriptPath "$scriptPath.backup-$timestamp"
Write-Host "[OK] Backup: Sync-FromNAS.ps1.backup-$timestamp" -ForegroundColor Green
Write-Host ""
Write-Host "[2] Reading script" -ForegroundColor Yellow
$content = Get-Content $scriptPath
Write-Host ""
Write-Host "[3] Fixing line 92" -ForegroundColor Yellow
Write-Host "Before:" -ForegroundColor Red
Write-Host " $($content[91])" -ForegroundColor Red
# Split line 92 at the "if" keyword
if ($content[91] -match '^(.+2>&1)\s+(if.+)$') {
$scpLine = $matches[1]
$ifLine = " $($matches[2])"
Write-Host ""
Write-Host "After:" -ForegroundColor Green
Write-Host " $scpLine" -ForegroundColor Green
Write-Host " $ifLine" -ForegroundColor Green
# Replace line 91 (0-indexed) with the SCP line and insert the if line
$newContent = @()
for ($i = 0; $i -lt $content.Count; $i++) {
if ($i -eq 91) {
$newContent += $scpLine
$newContent += $ifLine
} else {
$newContent += $content[$i]
}
}
Write-Host ""
Write-Host "[4] Saving fixed script" -ForegroundColor Yellow
$newContent | Out-File -FilePath $scriptPath -Encoding UTF8 -Force
Write-Host "[OK] Script saved" -ForegroundColor Green
Write-Host ""
Write-Host "[5] Verifying fix" -ForegroundColor Yellow
$updatedContent = Get-Content $scriptPath
Write-Host "Lines 92-95:" -ForegroundColor Cyan
for ($i = 91; $i -le 94; $i++) {
Write-Host " $($i+1): $($updatedContent[$i])" -ForegroundColor Gray
}
} else {
Write-Host "[ERROR] Could not parse line 92" -ForegroundColor Red
Write-Host "Line content: $($content[91])" -ForegroundColor Yellow
}
}
Write-Host ""
Write-Host "=== Fix Complete ===" -ForegroundColor Cyan

View File

@@ -0,0 +1,65 @@
# Fix NUL device references in DOS BAT files
# Replace with DOS 6.22 compatible tests
$BATFiles = @(
"DEPLOY.BAT",
"UPDATE.BAT",
"NWTOC.BAT",
"CTONW.BAT",
"CHECKUPD.BAT",
"AUTOEXEC.BAT",
"DOSTEST.BAT"
)
Write-Host "[INFO] Fixing NUL device references in BAT files..." -ForegroundColor Cyan
Write-Host ""
foreach ($File in $BATFiles) {
if (Test-Path $File) {
Write-Host "Processing: $File"
$Content = Get-Content $File -Raw
$OriginalSize = $Content.Length
# Fix 1: Replace "T: 2>NUL" with proper drive test
$Content = $Content -replace '([A-Z]:)\s+2>NUL', 'DIR $1\ >nul'
# Fix 2: Replace "IF NOT EXIST X:\NUL" with "IF NOT EXIST X:\*.*"
$Content = $Content -replace 'IF NOT EXIST ([A-Z]:\\)NUL', 'IF NOT EXIST $1*.*'
# Fix 3: Replace "IF NOT EXIST path\NUL" directory tests with proper test
# This matches patterns like "C:\BAT\NUL" or "T:\COMMON\NUL"
$Content = $Content -replace 'IF NOT EXIST ([A-Z]:\\[^\\]+(?:\\[^\\]+)*)\\NUL', 'IF NOT EXIST $1\*.*'
# Fix 4: Replace "IF EXIST path\NUL" with proper test
$Content = $Content -replace 'IF EXIST ([A-Z]:\\[^\\]+(?:\\[^\\]+)*)\\NUL', 'IF EXIST $1\*.*'
$NewSize = $Content.Length
if ($NewSize -ne $OriginalSize) {
# Verify still has CRLF
if ($Content -match "`r`n") {
Set-Content $File -Value $Content -NoNewline
Write-Host " [OK] Fixed NUL references (CRLF preserved)" -ForegroundColor Green
} else {
Write-Host " [ERROR] CRLF lost during fix!" -ForegroundColor Red
}
} else {
Write-Host " [OK] No NUL references found" -ForegroundColor Gray
}
Write-Host ""
} else {
Write-Host "[WARNING] $File not found" -ForegroundColor Yellow
Write-Host ""
}
}
Write-Host "[SUCCESS] NUL reference fixes complete" -ForegroundColor Green
Write-Host ""
Write-Host "Changes made:"
Write-Host " - 'T: 2>NUL' → 'DIR T:\ >nul'"
Write-Host " - 'IF NOT EXIST T:\NUL' → 'IF NOT EXIST T:\*.*'"
Write-Host " - 'IF NOT EXIST path\NUL' → 'IF NOT EXIST path\*.*'"
Write-Host ""
Write-Host "Note: These tests are DOS 6.22 compatible"

View File

@@ -0,0 +1,61 @@
# Fix PAUSE command syntax - DOS 6.22 does not accept message parameters
# Convert "PAUSE message..." to "ECHO message..." followed by "PAUSE"
$BATFiles = Get-ChildItem *.BAT | Where-Object {
$_.Name -notlike "*_FROM_*" -and
$_.Name -notlike "*_TEST*" -and
$_.Name -notlike "*_VERIFY*" -and
$_.Name -notlike "*_CHECK*" -and
$_.Name -notlike "*_MONITOR*"
}
Write-Host "[INFO] Fixing PAUSE syntax (DOS 6.22 does not accept message)" -ForegroundColor Cyan
Write-Host ""
$TotalFixed = 0
foreach ($File in $BATFiles) {
Write-Host "Processing: $($File.Name)" -ForegroundColor White
$Lines = Get-Content $File.FullName
$Modified = $false
$NewLines = @()
for ($i = 0; $i -lt $Lines.Count; $i++) {
$Line = $Lines[$i]
# Check if line starts with PAUSE followed by text
if ($Line -match '^(\s*)PAUSE\s+(.+)$') {
$Indent = $Matches[1]
$Message = $Matches[2]
# Replace with ECHO + PAUSE
$NewLines += "${Indent}ECHO $Message"
$NewLines += "${Indent}PAUSE"
$Modified = $true
$TotalFixed++
} else {
$NewLines += $Line
}
}
if ($Modified) {
$NewLines | Set-Content $File.FullName
Write-Host " [OK] Fixed PAUSE syntax" -ForegroundColor Green
} else {
Write-Host " [OK] No PAUSE issues found" -ForegroundColor Green
}
}
Write-Host ""
Write-Host "[SUCCESS] Fixed $TotalFixed PAUSE commands across all files" -ForegroundColor Green
Write-Host ""
Write-Host "DOS 6.22 PAUSE syntax:" -ForegroundColor Cyan
Write-Host " CORRECT:" -ForegroundColor Green
Write-Host " ECHO Press any key to continue..." -ForegroundColor White
Write-Host " PAUSE" -ForegroundColor White
Write-Host ""
Write-Host " INCORRECT (Windows NT/2000+):" -ForegroundColor Red
Write-Host " PAUSE Press any key to continue..." -ForegroundColor Red
Write-Host ""

View File

@@ -0,0 +1,54 @@
# Fix the remaining PLINK reference to use SSH
$password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("INTRANET\sysadmin", $password)
Write-Host "=== Fixing PLINK Usage ===" -ForegroundColor Cyan
Write-Host ""
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
$scriptPath = "C:\Shares\test\scripts\Sync-FromNAS.ps1"
Write-Host "[1] Creating backup" -ForegroundColor Yellow
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
Copy-Item $scriptPath "$scriptPath.backup-$timestamp"
Write-Host "[OK] Backup: Sync-FromNAS.ps1.backup-$timestamp" -ForegroundColor Green
Write-Host ""
Write-Host "[2] Reading current script" -ForegroundColor Yellow
$content = Get-Content $scriptPath
Write-Host "[3] Fixing line 54 (PLINK usage)" -ForegroundColor Yellow
for ($i = 0; $i -lt $content.Count; $i++) {
if ($i -eq 53) { # Line 54 (0-indexed = 53)
Write-Host "Old: $($content[$i])" -ForegroundColor Red
# Replace PLINK with SSH and update the command syntax
$content[$i] = ' $result = & $SSH -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile="C:\Shares\test\scripts\.ssh\known_hosts" -o PreferredAuthentications=password -o PubkeyAuthentication=no -o PasswordAuthentication=yes "$NAS_USER@$NAS_IP" $Command 2>&1'
Write-Host "New: $($content[$i])" -ForegroundColor Green
}
}
Write-Host ""
Write-Host "[4] Saving updated script" -ForegroundColor Yellow
$content | Out-File -FilePath $scriptPath -Encoding UTF8 -Force
Write-Host "[OK] Script saved" -ForegroundColor Green
Write-Host ""
Write-Host "[5] Verifying fix" -ForegroundColor Yellow
$updatedContent = Get-Content $scriptPath -Raw
if ($updatedContent -match '\$PLINK') {
Write-Host "[WARNING] Still found PLINK references!" -ForegroundColor Yellow
} else {
Write-Host "[SUCCESS] No PLINK references found" -ForegroundColor Green
}
if ($updatedContent -match '\$SSH.*StrictHostKeyChecking') {
Write-Host "[SUCCESS] SSH command properly configured" -ForegroundColor Green
}
}
Write-Host ""
Write-Host "=== Fix Complete ===" -ForegroundColor Cyan

View File

@@ -0,0 +1,33 @@
# Fix root BAT files - Replace UPDATE.BAT and delete DEPLOY.BAT
$Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential("INTRANET\sysadmin", $Password)
Write-Host "[INFO] Connecting to AD2..." -ForegroundColor Cyan
$Session = New-PSSession -ComputerName 192.168.0.6 -Credential $Credential -ErrorAction Stop
Write-Host "[OK] Connected to AD2" -ForegroundColor Green
# Copy new UPDATE.BAT to root
Write-Host "[INFO] Replacing UPDATE.BAT in root..." -ForegroundColor Cyan
Copy-Item "D:\ClaudeTools\UPDATE-ROOT.BAT" -Destination "C:\Shares\test\UPDATE.BAT" -ToSession $Session -ErrorAction Stop
Write-Host "[OK] UPDATE.BAT replaced (now calls T:\COMMON\ProdSW\DEPLOY.BAT)" -ForegroundColor Green
# Delete DEPLOY.BAT from root
Write-Host "[INFO] Deleting DEPLOY.BAT from root..." -ForegroundColor Cyan
Invoke-Command -Session $Session -ScriptBlock {
if (Test-Path "C:\Shares\test\DEPLOY.BAT") {
Remove-Item "C:\Shares\test\DEPLOY.BAT" -Force
Write-Host "[OK] DEPLOY.BAT deleted from root" -ForegroundColor Green
} else {
Write-Host "[INFO] DEPLOY.BAT not found in root (already removed?)" -ForegroundColor Yellow
}
}
# Verify final state
Write-Host "`n[INFO] Verifying root BAT files..." -ForegroundColor Cyan
Invoke-Command -Session $Session -ScriptBlock {
Write-Host "`nBAT files in C:\Shares\test\:" -ForegroundColor Cyan
Get-ChildItem "C:\Shares\test\*.BAT" | Select-Object Name, Length, LastWriteTime | Format-Table -AutoSize
}
Remove-PSSession $Session
Write-Host "[SUCCESS] Root BAT files fixed" -ForegroundColor Green

View File

@@ -0,0 +1,95 @@
# Fix root UPDATE.BAT - Deploy correct redirect script
# Date: 2026-01-20
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Fixing Root UPDATE.BAT" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# AD2 Connection Details
$AD2Host = "192.168.0.6"
$Username = "INTRANET\sysadmin"
$Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential($Username, $Password)
# Source file - the redirect script
$SourceFile = "D:\ClaudeTools\UPDATE-ROOT.BAT"
$DestFile = "\\$AD2Host\C$\Shares\test\UPDATE.BAT"
# Verify source file exists
if (-not (Test-Path $SourceFile)) {
Write-Host "[ERROR] Source file not found: $SourceFile" -ForegroundColor Red
exit 1
}
Write-Host "[OK] Source file found: $SourceFile" -ForegroundColor Green
Write-Host ""
# Map network drive
Write-Host "Connecting to AD2..." -ForegroundColor Yellow
try {
New-PSDrive -Name TEMP_AD2 -PSProvider FileSystem -Root "\\$AD2Host\C$" -Credential $Cred -ErrorAction Stop | Out-Null
Write-Host "[OK] Connected to AD2" -ForegroundColor Green
Write-Host ""
} catch {
Write-Host "[ERROR] Failed to connect to AD2: $_" -ForegroundColor Red
exit 1
}
# Check if DEPLOY.BAT exists in root (should NOT exist)
Write-Host "Checking for DEPLOY.BAT in root..." -ForegroundColor Yellow
$DeployInRoot = "\\$AD2Host\C$\Shares\test\DEPLOY.BAT"
if (Test-Path $DeployInRoot) {
Write-Host "[WARNING] DEPLOY.BAT found in root - will delete" -ForegroundColor Yellow
Remove-Item $DeployInRoot -Force
Write-Host "[OK] DEPLOY.BAT deleted from root" -ForegroundColor Green
} else {
Write-Host "[OK] DEPLOY.BAT not in root (correct)" -ForegroundColor Green
}
Write-Host ""
# Deploy correct UPDATE.BAT (redirect script) to root
Write-Host "Deploying UPDATE.BAT redirect script to root..." -ForegroundColor Yellow
try {
Copy-Item -Path $SourceFile -Destination $DestFile -Force -ErrorAction Stop
Write-Host "[OK] UPDATE.BAT redirect deployed to root" -ForegroundColor Green
Write-Host ""
} catch {
Write-Host "[ERROR] Failed to deploy: $_" -ForegroundColor Red
Remove-PSDrive -Name TEMP_AD2 -ErrorAction SilentlyContinue
exit 1
}
# Verify content
Write-Host "Verifying UPDATE.BAT content..." -ForegroundColor Yellow
$Content = Get-Content $DestFile -Raw
if ($Content -like "*CALL T:\COMMON\ProdSW\DEPLOY.BAT*") {
Write-Host "[OK] UPDATE.BAT correctly calls DEPLOY.BAT" -ForegroundColor Green
} else {
Write-Host "[ERROR] UPDATE.BAT does not contain correct redirect!" -ForegroundColor Red
}
Write-Host ""
# Show root BAT files
Write-Host "Root BAT files in C:\Shares\test\:" -ForegroundColor Cyan
Get-ChildItem "\\$AD2Host\C$\Shares\test\*.BAT" -ErrorAction SilentlyContinue |
Select-Object Name, Length, LastWriteTime |
Format-Table -AutoSize
# Cleanup
Remove-PSDrive -Name TEMP_AD2 -ErrorAction SilentlyContinue
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Fix Complete" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Correct structure:" -ForegroundColor Yellow
Write-Host " T:\UPDATE.BAT -> Redirect to DEPLOY.BAT" -ForegroundColor White
Write-Host " T:\COMMON\ProdSW\DEPLOY.BAT -> Deployment installer" -ForegroundColor White
Write-Host " T:\COMMON\ProdSW\UPDATE.BAT -> Backup utility (v2.1)" -ForegroundColor White
Write-Host ""
Write-Host "Usage on DOS machine:" -ForegroundColor Yellow
Write-Host " T:\UPDATE TS-4R -> Runs deployment for TS-4R" -ForegroundColor White
Write-Host ""
Write-Host "After deployment, backup utility is at:" -ForegroundColor Yellow
Write-Host " C:\BAT\UPDATE.BAT -> Full backup utility" -ForegroundColor White

View File

@@ -0,0 +1,50 @@
$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password)
Write-Host "================================================" -ForegroundColor Cyan
Write-Host "Fixing SSH Agent on AD2" -ForegroundColor Cyan
Write-Host "================================================" -ForegroundColor Cyan
Write-Host ""
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
Write-Host "[1/4] Starting SSH Agent service..." -ForegroundColor Yellow
try {
Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent
Write-Host " [OK] SSH Agent started" -ForegroundColor Green
} catch {
Write-Host " [ERROR] Failed to start SSH Agent: $($_.Exception.Message)" -ForegroundColor Red
}
Start-Sleep -Seconds 2
Write-Host ""
Write-Host "[2/4] Adding private key to agent..." -ForegroundColor Yellow
$keyFile = "$env:USERPROFILE\.ssh\id_ed25519"
$sshAdd = & "C:\Program Files\OpenSSH\ssh-add.exe" $keyFile 2>&1
Write-Host " Result: $sshAdd" -ForegroundColor White
Write-Host ""
Write-Host "[3/4] Verifying key is loaded..." -ForegroundColor Yellow
$sshList = & "C:\Program Files\OpenSSH\ssh-add.exe" -l 2>&1
Write-Host " Loaded keys: $sshList" -ForegroundColor White
Write-Host ""
Write-Host "[4/4] Testing SSH connection now..." -ForegroundColor Yellow
try {
$env:SSH_AUTH_SOCK = (Get-Service ssh-agent | Get-ItemProperty -Name ImagePath).ImagePath
$result = cmd /c "echo | C:\Progra~1\OpenSSH\ssh.exe -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@192.168.0.9 hostname 2>&1"
if ($LASTEXITCODE -eq 0) {
Write-Host " [OK] SSH CONNECTION SUCCESSFUL: $result" -ForegroundColor Green
} else {
Write-Host " [ERROR] SSH still failing: $result" -ForegroundColor Red
}
} catch {
Write-Host " [ERROR] Exception: $($_.Exception.Message)" -ForegroundColor Red
}
}
Write-Host ""
Write-Host "================================================" -ForegroundColor Cyan
Write-Host "SSH Agent Fix Complete" -ForegroundColor Cyan
Write-Host "================================================" -ForegroundColor Cyan

View File

@@ -0,0 +1,135 @@
# Fix the sync functions more precisely
$password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("INTRANET\sysadmin", $password)
Write-Host "=== Fixing Sync Script Functions ===" -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] Finding Copy-FromNAS function" -ForegroundColor Yellow
Write-Host "=" * 80 -ForegroundColor Gray
# Find the function
for ($i = 0; $i -lt $content.Count; $i++) {
if ($content[$i] -match "^function Copy-FromNAS") {
Write-Host "Found at line $($i+1): $($content[$i])" -ForegroundColor Green
# Show the function (next 10 lines)
Write-Host "Current function:" -ForegroundColor Cyan
for ($j = $i; $j -lt ($i + 10) -and $j -lt $content.Count; $j++) {
Write-Host " $($j+1): $($content[$j])" -ForegroundColor Gray
}
break
}
}
Write-Host ""
Write-Host "[2] Finding Copy-ToNAS function" -ForegroundColor Yellow
Write-Host "=" * 80 -ForegroundColor Gray
for ($i = 0; $i -lt $content.Count; $i++) {
if ($content[$i] -match "^function Copy-ToNAS") {
Write-Host "Found at line $($i+1): $($content[$i])" -ForegroundColor Green
# Show the function (next 10 lines)
Write-Host "Current function:" -ForegroundColor Cyan
for ($j = $i; $j -lt ($i + 10) -and $j -lt $content.Count; $j++) {
Write-Host " $($j+1): $($content[$j])" -ForegroundColor Gray
}
break
}
}
Write-Host ""
Write-Host "[3] Creating updated script with OpenSSH" -ForegroundColor Yellow
Write-Host "=" * 80 -ForegroundColor Gray
# Create new script content with line-by-line replacement
$newContent = @()
$inCopyFromNAS = $false
$inCopyToNAS = $false
$funcDepth = 0
for ($i = 0; $i -lt $content.Count; $i++) {
$line = $content[$i]
# Track when we enter functions
if ($line -match "^function Copy-FromNAS") {
$inCopyFromNAS = $true
$funcDepth = 0
$newContent += "function Copy-FromNAS {"
$newContent += " param([string]`$RemotePath, [string]`$LocalPath)"
$newContent += ""
$newContent += " # OpenSSH scp with verbose logging"
$newContent += " `$result = & `$SCP -v -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=`"`$SCRIPTS_DIR\.ssh\known_hosts`" `"`${NAS_USER}@`${NAS_IP}:`$RemotePath`" `$LocalPath 2>&1"
$newContent += ""
$newContent += " if (`$LASTEXITCODE -ne 0) {"
$newContent += " Write-Log `" SCP PULL ERROR: `$(`$result | Out-String)`""
$newContent += " }"
$newContent += ""
$newContent += " return `$LASTEXITCODE -eq 0"
$newContent += "}"
# Skip until we find the closing brace
continue
}
if ($line -match "^function Copy-ToNAS") {
$inCopyToNAS = $true
$funcDepth = 0
$newContent += "function Copy-ToNAS {"
$newContent += " param([string]`$LocalPath, [string]`$RemotePath)"
$newContent += ""
$newContent += " # OpenSSH scp with verbose logging"
$newContent += " `$result = & `$SCP -v -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=`"`$SCRIPTS_DIR\.ssh\known_hosts`" `$LocalPath `"`${NAS_USER}@`${NAS_IP}:`$RemotePath`" 2>&1"
$newContent += ""
$newContent += " if (`$LASTEXITCODE -ne 0) {"
$newContent += " Write-Log `" SCP PUSH ERROR: `$(`$result | Out-String)`""
$newContent += " }"
$newContent += ""
$newContent += " return `$LASTEXITCODE -eq 0"
$newContent += "}"
# Skip until we find the closing brace
continue
}
# Track braces when inside function
if ($inCopyFromNAS -or $inCopyToNAS) {
if ($line -match "{") { $funcDepth++ }
if ($line -match "}") {
$funcDepth--
if ($funcDepth -le 0) {
# End of function, stop skipping
$inCopyFromNAS = $false
$inCopyToNAS = $false
}
}
# Skip lines inside the old function
continue
}
# Update tool paths
if ($line -match '\$PSCP\s*=') {
$newContent += '$SCP = "C:\Program Files\OpenSSH\scp.exe"'
continue
}
if ($line -match '\$PLINK\s*=') {
$newContent += '$SSH = "C:\Program Files\OpenSSH\ssh.exe"'
continue
}
# Keep all other lines
$newContent += $line
}
# Save the updated script
$newContent | Out-File -FilePath $scriptPath -Encoding UTF8 -Force
Write-Host "[OK] Script updated with OpenSSH functions" -ForegroundColor Green
Write-Host "[OK] Saved: $scriptPath" -ForegroundColor Green
}
Write-Host ""
Write-Host "=== Update Complete ===" -ForegroundColor Cyan

View File

@@ -0,0 +1,35 @@
$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password)
Write-Host "Fixing Sync Script SSH Commands..." -ForegroundColor Cyan
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
$scriptPath = "C:\Shares\test\scripts\Sync-FromNAS.ps1"
$backupPath = "C:\Shares\test\scripts\Sync-FromNAS.ps1.backup-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
Write-Host "[1] Backing up current script..." -ForegroundColor Yellow
Copy-Item $scriptPath $backupPath
Write-Host " Backup: $backupPath" -ForegroundColor Green
Write-Host ""
Write-Host "[2] Reading current script..." -ForegroundColor Yellow
$content = Get-Content $scriptPath -Raw
Write-Host ""
Write-Host "[3] Adding SSH key parameter to all SSH/SCP commands..." -ForegroundColor Yellow
$sshKeyPath = "$env:USERPROFILE\.ssh\id_ed25519"
# Replace ssh commands to include -i flag
$content = $content -replace 'ssh\s+root@', "ssh -i `"$sshKeyPath`" -o BatchMode=yes -o ConnectTimeout=10 root@"
# Replace scp commands to include -i flag
$content = $content -replace 'scp\s+', "scp -i `"$sshKeyPath`" -o BatchMode=yes -o ConnectTimeout=10 "
Write-Host ""
Write-Host "[4] Writing updated script..." -ForegroundColor Yellow
$content | Out-File $scriptPath -Encoding UTF8 -Force
Write-Host " [OK] Script updated" -ForegroundColor Green
Write-Host ""
Write-Host "[5] Verifying changes (showing first SSH command)..." -ForegroundColor Yellow
$content | Select-String "ssh -i" | Select-Object -First 3 | ForEach-Object { Write-Host " $_" -ForegroundColor Gray }
}

View File

@@ -0,0 +1,80 @@
$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password)
Write-Host "================================================" -ForegroundColor Cyan
Write-Host "Fixing Sync Task User Account" -ForegroundColor Cyan
Write-Host "================================================" -ForegroundColor Cyan
Write-Host ""
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
Write-Host "[1] Checking current task configuration..." -ForegroundColor Yellow
$task = Get-ScheduledTask -TaskName "Sync-FromNAS"
Write-Host " Current user: $($task.Principal.UserId)" -ForegroundColor White
Write-Host " Run level: $($task.Principal.RunLevel)" -ForegroundColor White
Write-Host ""
Write-Host "[2] Reconfiguring task to run as sysadmin..." -ForegroundColor Yellow
# Get the current task definition
$taskAction = $task.Actions[0]
$taskTrigger = $task.Triggers[0]
$taskSettings = $task.Settings
# Create password for sysadmin
$taskPassword = 'Paper123!@#'
# Unregister old task
Unregister-ScheduledTask -TaskName "Sync-FromNAS" -Confirm:$false
# Register new task with sysadmin user
$action = New-ScheduledTaskAction -Execute $taskAction.Execute -Argument $taskAction.Arguments -WorkingDirectory $taskAction.WorkingDirectory
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 15) -RepetitionDuration ([TimeSpan]::MaxValue)
$settings = New-ScheduledTaskSettingsSet `
-AllowStartIfOnBatteries `
-DontStopIfGoingOnBatteries `
-StartWhenAvailable `
-ExecutionTimeLimit (New-TimeSpan -Minutes 30)
Register-ScheduledTask `
-TaskName "Sync-FromNAS" `
-Action $action `
-Trigger $trigger `
-Settings $settings `
-User "INTRANET\sysadmin" `
-Password $taskPassword `
-RunLevel Highest `
-Force | Out-Null
Write-Host " [OK] Task reconfigured to run as INTRANET\sysadmin" -ForegroundColor Green
Write-Host ""
Write-Host "[3] Verifying new configuration..." -ForegroundColor Yellow
$newTask = Get-ScheduledTask -TaskName "Sync-FromNAS"
Write-Host " New user: $($newTask.Principal.UserId)" -ForegroundColor White
Write-Host " State: $($newTask.State)" -ForegroundColor White
Write-Host ""
Write-Host "[4] Testing sync task..." -ForegroundColor Yellow
Start-ScheduledTask -TaskName "Sync-FromNAS"
Write-Host " Task started - waiting 20 seconds..." -ForegroundColor White
Start-Sleep -Seconds 20
Write-Host ""
Write-Host "[5] Checking sync log..." -ForegroundColor Yellow
if (Test-Path "C:\Shares\test\scripts\sync-from-nas.log") {
$lastLog = Get-Content "C:\Shares\test\scripts\sync-from-nas.log" | Select-Object -Last 15
$lastLog | ForEach-Object { Write-Host " $_" -ForegroundColor Gray }
}
Write-Host ""
Write-Host "[6] Checking task status..." -ForegroundColor Yellow
$taskInfo = Get-ScheduledTaskInfo -TaskName "Sync-FromNAS"
Write-Host " Last Run: $($taskInfo.LastRunTime)" -ForegroundColor White
Write-Host " Last Result: 0x$($taskInfo.LastTaskResult.ToString('X'))" -ForegroundColor $(if ($taskInfo.LastTaskResult -eq 0) { "Green" } else { "Red" })
Write-Host " Next Run: $($taskInfo.NextRunTime)" -ForegroundColor White
}
Write-Host ""
Write-Host "================================================" -ForegroundColor Cyan
Write-Host "Task User Fix Complete" -ForegroundColor Cyan
Write-Host "================================================" -ForegroundColor Cyan

View File

@@ -0,0 +1,27 @@
$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password)
Write-Host "Fixing Sync Script to Use SSH Keys..." -ForegroundColor Cyan
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
$scriptPath = "C:\Shares\test\scripts\Sync-FromNAS.ps1"
Write-Host "[1] Reading script..." -ForegroundColor Yellow
$content = Get-Content $scriptPath -Raw
Write-Host "[2] Removing password authentication options..." -ForegroundColor Yellow
# Remove all the password auth options and replace with key auth
$content = $content -replace '-o PreferredAuthentications=password -o PubkeyAuthentication=no -o PasswordAuthentication=yes', ''
# Add SSH key to Invoke-NASCommand function
$content = $content -replace '(\$SSH -o StrictHostKeyChecking)', '$$SSH -i "C:\Users\sysadmin\.ssh\id_ed25519" -o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking'
Write-Host "[3] Writing fixed script..." -ForegroundColor Yellow
$content | Out-File $scriptPath -Encoding UTF8 -Force
Write-Host " [OK] Script updated to use SSH keys" -ForegroundColor Green
Write-Host ""
Write-Host "[4] Showing fixed Invoke-NASCommand..." -ForegroundColor Yellow
$content | Select-String -Pattern "Invoke-NASCommand" -Context 0,5 | Select-Object -First 1
}

View File

@@ -0,0 +1,74 @@
$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password)
Write-Host "================================================" -ForegroundColor Cyan
Write-Host "Fixing Zombie Sync Task" -ForegroundColor Cyan
Write-Host "================================================" -ForegroundColor Cyan
Write-Host ""
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
Write-Host "[1/5] Stopping zombie sync task..." -ForegroundColor Yellow
try {
Stop-ScheduledTask -TaskName "Sync-FromNAS" -ErrorAction Stop
Write-Host " [OK] Task stopped" -ForegroundColor Green
} catch {
Write-Host " [ERROR] Failed to stop task: $($_.Exception.Message)" -ForegroundColor Red
}
Start-Sleep -Seconds 2
Write-Host ""
Write-Host "[2/5] Killing any hung PowerShell processes..." -ForegroundColor Yellow
$hungProcs = Get-Process -Name pwsh,powershell -ErrorAction SilentlyContinue |
Where-Object { $_.StartTime -lt (Get-Date).AddHours(-1) }
if ($hungProcs) {
$hungProcs | ForEach-Object {
Write-Host " Killing PID $($_.Id) (started $($_.StartTime))" -ForegroundColor White
Stop-Process -Id $_.Id -Force
}
Write-Host " [OK] Killed $($hungProcs.Count) hung process(es)" -ForegroundColor Green
} else {
Write-Host " [OK] No hung processes found" -ForegroundColor Green
}
Write-Host ""
Write-Host "[3/5] Testing SSH connectivity to NAS..." -ForegroundColor Yellow
$sshTest = & ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@192.168.0.9 "hostname" 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host " [OK] SSH connection successful: $sshTest" -ForegroundColor Green
} else {
Write-Host " [ERROR] SSH connection failed: $sshTest" -ForegroundColor Red
Write-Host " Attempting to test with password auth..." -ForegroundColor Yellow
}
Write-Host ""
Write-Host "[4/5] Testing NAS find command (what was hanging)..." -ForegroundColor Yellow
$findTest = & ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@192.168.0.9 "find /data/test/TS-4R/LOGS -name '*.DAT' -type f 2>/dev/null | head -5" 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host " [OK] Find command executed successfully" -ForegroundColor Green
Write-Host " Sample results: $($findTest -join ', ')" -ForegroundColor Gray
} else {
Write-Host " [ERROR] Find command failed: $findTest" -ForegroundColor Red
}
Write-Host ""
Write-Host "[5/5] Re-enabling sync task..." -ForegroundColor Yellow
try {
Start-ScheduledTask -TaskName "Sync-FromNAS" -ErrorAction Stop
Write-Host " [OK] Task re-enabled and started" -ForegroundColor Green
} catch {
Write-Host " [ERROR] Failed to start task: $($_.Exception.Message)" -ForegroundColor Red
}
Write-Host ""
Write-Host "[VERIFICATION] Task status after fix..." -ForegroundColor Yellow
$task = Get-ScheduledTask -TaskName "Sync-FromNAS"
$taskInfo = Get-ScheduledTaskInfo -TaskName "Sync-FromNAS"
Write-Host " State: $($task.State)" -ForegroundColor White
Write-Host " Last Run: $($taskInfo.LastRunTime)" -ForegroundColor White
Write-Host " Next Run: $($taskInfo.NextRunTime)" -ForegroundColor White
}
Write-Host ""
Write-Host "================================================" -ForegroundColor Cyan
Write-Host "Fix Complete - Monitor sync log for results" -ForegroundColor Cyan
Write-Host "================================================" -ForegroundColor Cyan

View File

@@ -0,0 +1,62 @@
# Fix XCOPY /Q switch - not supported in DOS 6.22
# Removes /Q switch from all XCOPY commands
$BATFiles = @(
"DEPLOY.BAT",
"UPDATE.BAT",
"CTONW.BAT",
"NWTOC.BAT",
"DEPLOY_VERIFY.BAT",
"DEPLOY_TEST.BAT",
"DEPLOY_FROM_NAS.BAT",
"DEPLOY_FROM_AD2.BAT"
)
Write-Host "[INFO] Fixing XCOPY /Q switches (not in DOS 6.22)" -ForegroundColor Cyan
Write-Host ""
$TotalFixed = 0
foreach ($File in $BATFiles) {
$FilePath = "D:\ClaudeTools\$File"
if (-not (Test-Path $FilePath)) {
Write-Host "[SKIP] $File - not found" -ForegroundColor Yellow
continue
}
Write-Host "Processing: $File" -ForegroundColor White
$Content = Get-Content $FilePath -Raw
$OriginalContent = $Content
# Remove /Q switch from XCOPY commands
# Pattern: XCOPY ... /Y /Q -> XCOPY ... /Y
# Pattern: XCOPY ... /Q -> XCOPY ...
$Content = $Content -replace '(\s+)\/Q(\s+)', '$1$2'
$Content = $Content -replace '(\s+)\/Q(\r?\n)', '$1$2'
if ($Content -ne $OriginalContent) {
$ChangeCount = ([regex]::Matches($OriginalContent, '/Q')).Count
Set-Content $FilePath $Content -NoNewline
Write-Host " [OK] Removed $ChangeCount /Q switches" -ForegroundColor Green
$TotalFixed += $ChangeCount
} else {
Write-Host " [OK] No /Q switches found" -ForegroundColor Green
}
}
Write-Host ""
Write-Host "[SUCCESS] Fixed $TotalFixed /Q switches across all files" -ForegroundColor Green
Write-Host ""
Write-Host "DOS 6.22 XCOPY switches (valid):" -ForegroundColor Cyan
Write-Host " /Y Suppress prompts (OK)" -ForegroundColor White
Write-Host " /S Copy subdirectories (OK)" -ForegroundColor White
Write-Host " /E Copy empty subdirectories (OK)" -ForegroundColor White
Write-Host " /D Only copy newer files (OK)" -ForegroundColor White
Write-Host " /H Copy hidden files (OK)" -ForegroundColor White
Write-Host " /K Copy attributes (OK)" -ForegroundColor White
Write-Host " /C Continue on errors (OK)" -ForegroundColor White
Write-Host ""
Write-Host " /Q Quiet mode (NOT SUPPORTED)" -ForegroundColor Red
Write-Host ""

View File

@@ -0,0 +1,94 @@
# Push Fixed BAT Files Directly to NAS
# Bypasses AD2 sync - direct deployment to D2TESTNAS
# Date: 2026-01-20
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Direct NAS Deployment (Bypass AD2 Sync)" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# Files to deploy (all latest versions)
$Files = @(
"AUTOEXEC.BAT",
"UPDATE.BAT", # v2.2
"DEPLOY.BAT",
"NWTOC.BAT", # v2.2
"CTONW.BAT", # v2.1
"CHECKUPD.BAT", # v1.2
"STAGE.BAT",
"REBOOT.BAT",
"DOSTEST.BAT" # v1.1
)
# NAS connection details
$NASHost = "192.168.0.9"
$NASUser = "root"
$DestPath = "/data/test/COMMON/ProdSW"
Write-Host "Copying files to D2TESTNAS..." -ForegroundColor Yellow
Write-Host "Target: $NASHost`:$DestPath" -ForegroundColor Gray
Write-Host ""
$SuccessCount = 0
$FailCount = 0
foreach ($File in $Files) {
$SourceFile = "D:\ClaudeTools\$File"
if (-not (Test-Path $SourceFile)) {
Write-Host " [SKIP] $File (not found locally)" -ForegroundColor Yellow
continue
}
Write-Host " Copying $File..." -NoNewline
try {
# Use pscp.exe to copy via SSH (passwordless with key)
# Convert Windows path to WSL/Linux format for pscp
$UnixSource = $SourceFile -replace '\\', '/'
$UnixSource = $UnixSource -replace 'D:', '/mnt/d'
# Use pscp from PuTTY tools
& pscp.exe -batch -i C:\Users\MikeSwanson\.ssh\id_ed25519 "$SourceFile" "${NASUser}@${NASHost}:${DestPath}/${File}" 2>&1 | Out-Null
if ($LASTEXITCODE -eq 0) {
Write-Host " [OK]" -ForegroundColor Green
$SuccessCount++
} else {
Write-Host " [FAILED]" -ForegroundColor Red
$FailCount++
}
} catch {
Write-Host " [ERROR] $_" -ForegroundColor Red
$FailCount++
}
}
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Deployment Summary" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Successful: $SuccessCount" -ForegroundColor Green
Write-Host "Failed: $FailCount" -ForegroundColor $(if ($FailCount -eq 0) { "Green" } else { "Red" })
Write-Host ""
if ($SuccessCount -gt 0) {
Write-Host "Files are now available on NAS at:" -ForegroundColor Yellow
Write-Host " T:\COMMON\ProdSW\" -ForegroundColor White
Write-Host ""
Write-Host "Test on TS-4R immediately:" -ForegroundColor Yellow
Write-Host " C:\BAT\NWTOC - Download updates" -ForegroundColor White
Write-Host " C:\BAT\UPDATE - Test backup" -ForegroundColor White
Write-Host " C:\BAT\CHECKUPD - Check for updates" -ForegroundColor White
Write-Host ""
Write-Host "Latest versions deployed:" -ForegroundColor Cyan
Write-Host " UPDATE.BAT v2.2 - XCOPY fix + Drive test fix" -ForegroundColor Gray
Write-Host " NWTOC.BAT v2.2 - XCOPY fix + Drive test fix" -ForegroundColor Gray
Write-Host " CTONW.BAT v2.1 - Drive test fix" -ForegroundColor Gray
Write-Host " CHECKUPD.BAT v1.2 - XCOPY fix + Drive test fix" -ForegroundColor Gray
Write-Host " DOSTEST.BAT v1.1 - Drive test fix" -ForegroundColor Gray
} else {
Write-Host "[ERROR] No files copied successfully!" -ForegroundColor Red
Write-Host "Check SSH key and NAS connectivity" -ForegroundColor Yellow
}