Files
claudetools/scratch-preseed.ps1
Howard Enos 2fd646218d sync: auto-sync from HOWARD-HOME at 2026-07-07 17:33:19
Author: Howard Enos
Machine: HOWARD-HOME
Timestamp: 2026-07-07 17:33:19
2026-07-07 17:33:56 -07:00

16 lines
1.2 KiB
PowerShell

$ErrorActionPreference='Stop'
$log='C:\Windows\Temp\tps-preseed.log'
# Pre-seed: data+attributes+timestamps only (ACLs re-applied fresh at cutover, avoids remote-privilege issues).
# /B backup mode reads open/locked files where possible; locked live QB .QBW skips fast (/R:1) and is recopied clean at cutover.
$rc = 'robocopy "C:\Share" "\\TPS-SVR\Share" /E /COPY:DAT /DCOPY:DAT /B /R:1 /W:2 /Z /XJ /MT:16 /NFL /NDL /NP /LOG:' + $log
$action = New-ScheduledTaskAction -Execute 'cmd.exe' -Argument ('/c ' + $rc)
$principal = New-ScheduledTaskPrincipal -UserId 'NT AUTHORITY\SYSTEM' -LogonType ServiceAccount -RunLevel Highest
$settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Hours 12) -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
$task = New-ScheduledTask -Action $action -Principal $principal -Settings $settings
Register-ScheduledTask -TaskName 'TPS-Preseed-Copy' -InputObject $task -Force | Out-Null
Start-ScheduledTask -TaskName 'TPS-Preseed-Copy'
Start-Sleep -Seconds 12
"Task state: $((Get-ScheduledTask -TaskName 'TPS-Preseed-Copy').State)"
"-- log head --"
if(Test-Path $log){ Get-Content $log -TotalCount 14 } else { "(log not created yet)" }