$LogDir = "C:\MinerOpsAgent\logs" $LogFile = Join-Path $LogDir "pool-poller.log" if (-not (Test-Path $LogDir)) { New-Item -ItemType Directory -Path $LogDir -Force | Out-Null } $stamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" try { Add-Content -Path $LogFile -Value "$stamp Starting MinerOps pool poller." $output = powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\MinerOpsAgent\MinerOpsPoolPoller.ps1" 2>&1 foreach ($line in $output) { Add-Content -Path $LogFile -Value "$line" } $stamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" Add-Content -Path $LogFile -Value "$stamp Pool poller finished." Add-Content -Path $LogFile -Value "" } catch { $stamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" Add-Content -Path $LogFile -Value "$stamp Pool poller failed: $($_.Exception.Message)" Add-Content -Path $LogFile -Value "" exit 1 }