Files
claudetools/tmp_bulksync.ps1
Mike Swanson 8b6f0bcc96 sync: Multi-project updates - SolverBot, GuruRMM, Dataforth
SolverBot:
- Inject active project path into agent system prompts so agents
  know which directory to scope file operations to

GuruRMM:
- Bump agent version to 0.6.0
- Add serde aliases for PowerShell/ClaudeTask command types
- Add typed CommandType enum on server for proper serialization
- Support claude_task command type in send_command API

Dataforth:
- Fix SCP space-escaping in Sync-FromNAS.ps1

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 16:16:18 -07:00

57 lines
3.0 KiB
PowerShell

$pass = ConvertTo-SecureString ("Paper123" + [char]33 + "@#") -AsPlainText -Force
$cred = New-Object PSCredential("INTRANET\sysadmin", $pass)
$uncRoot = "\\192.168.0.6\C$"
New-PSDrive -Name AD2 -PSProvider FileSystem -Root $uncRoot -Credential $cred -ErrorAction Stop | Out-Null
# Write a one-time bulk sync runner script
$bulkScript = @"
# One-time bulk sync with 86400 minute window (60 days)
# This catches all stranded files from the last ~35 days
# Auto-deletes itself after running
Set-Location "C:\Shares\test\scripts"
& powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Shares\test\scripts\Sync-FromNAS.ps1" -MaxAgeMinutes 86400 -Verbose
# Log completion
Add-Content -Path "C:\Shares\test\scripts\sync-from-nas.log" -Value "$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss')) : BULK SYNC COMPLETE - one-time catchup finished"
# Clean up this trigger script
Remove-Item -Path "C:\Shares\test\scripts\BulkSync-OneTime.ps1" -Force -ErrorAction SilentlyContinue
"@
Set-Content -Path "AD2:\Shares\test\scripts\BulkSync-OneTime.ps1" -Value $bulkScript
Write-Output "[OK] Bulk sync script written to AD2:\Shares\test\scripts\BulkSync-OneTime.ps1"
# Now create a scheduled task on AD2 to run it immediately
# We can do this by writing a schtasks command file
$taskScript = @"
schtasks /create /tn "BulkSync-OneTime" /tr "powershell -NoProfile -ExecutionPolicy Bypass -File C:\Shares\test\scripts\BulkSync-OneTime.ps1" /sc once /st 00:00 /ru INTRANET\sysadmin /rp "Paper123\!@#" /f
schtasks /run /tn "BulkSync-OneTime"
"@
Set-Content -Path "AD2:\Shares\test\scripts\run-bulk.cmd" -Value $taskScript
Write-Output "[OK] Task creation script written"
Write-Output ""
Write-Output "NOTE: The scheduled task needs to be triggered on AD2."
Write-Output "Attempting to use WMI to create process on AD2..."
# Try WMI process creation (may work even if WinRM doesnt)
try {
$proc = Invoke-WmiMethod -ComputerName 192.168.0.6 -Credential $cred -Class Win32_Process -Name Create -ArgumentList "powershell -NoProfile -ExecutionPolicy Bypass -File C:\Shares\test\scripts\BulkSync-OneTime.ps1"
if ($proc.ReturnValue -eq 0) {
Write-Output "[OK] WMI process started on AD2\! PID: $($proc.ProcessId)"
} else {
Write-Output "[ERROR] WMI process creation failed with return value: $($proc.ReturnValue)"
}
} catch {
Write-Output "[ERROR] WMI failed: $_"
Write-Output "Trying schtasks approach..."
try {
$schResult = schtasks /create /s 192.168.0.6 /u INTRANET\sysadmin /p "Paper123\!@#" /tn "BulkSync-OneTime" /tr "powershell -NoProfile -ExecutionPolicy Bypass -File C:\Shares\test\scripts\BulkSync-OneTime.ps1" /sc once /st 00:00 /ru INTRANET\sysadmin /rp "Paper123\!@#" /f 2>&1
Write-Output "schtasks create: $schResult"
$runResult = schtasks /run /s 192.168.0.6 /u INTRANET\sysadmin /p "Paper123\!@#" /tn "BulkSync-OneTime" 2>&1
Write-Output "schtasks run: $runResult"
} catch {
Write-Output "[ERROR] schtasks also failed: $_"
}
}
Remove-PSDrive -Name AD2 -ErrorAction SilentlyContinue