foam_sync.ps1 (LIFEBALANCE) 2025-06-19T01:18:48Z

This commit is contained in:
Ben Miller
2025-06-19 01:18:48 -06:00
parent c1cc8b482e
commit 72523d1785

View File

@ -97,14 +97,15 @@ try {
# e.g., -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "Start-Process -FilePath powershell.exe -ArgumentList '-NoProfile -NonInteractive -ExecutionPolicy Bypass -File \"C:\path\to your script.ps1\"' -WindowStyle Hidden"
# $actionArgumentForRegistration = "-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command \`"$commandToRunViaStartProcess\`""
# TEMPORARY: For troubleshooting the flashing window. This will create an error log for the intermediate powershell.
$intermediateErrorLog = Join-Path -Path $logDir -ChildPath "intermediate_error.log"
$actionArgumentForRegistration = "-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command \`"$commandToRunViaStartProcess 2> '$intermediateErrorLog'\`""
# TEMPORARY: For troubleshooting the flashing window.
# We simplify the command to see if the intermediate PowerShell itself has an issue parsing/executing Start-Process.
# Errors from this *intermediate* powershell should appear in the Task Scheduler history.
$actionArgumentForRegistration = "-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command \`"$commandToRunViaStartProcess\`"" # Reverted to original, but without explicit redirection for now.
# 6. Expected argument string WHEN RETRIEVED by Get-ScheduledTask.
# Task Scheduler/PowerShell often strips the outermost quotes from the -Command value when retrieved.
$expectedRetrievedActionArgument = "-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command $commandToRunViaStartProcess 2> '$intermediateErrorLog'" # Match the temporary change
$expectedRetrievedActionArgument = "-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command $commandToRunViaStartProcess" # Reverted to match the above
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument $actionArgumentForRegistration