From 9bf28eb3c87dd0a00f38199d263df3e69b30adc0 Mon Sep 17 00:00:00 2001 From: Daniel Kucinski Date: Mon, 14 Sep 2026 10:13:21 -0700 Subject: [PATCH] chore: sync Scout skills 2026-09-14 --- install-system-sync-task.ps1 | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/install-system-sync-task.ps1 b/install-system-sync-task.ps1 index c1fa9a4..f9d5091 100644 --- a/install-system-sync-task.ps1 +++ b/install-system-sync-task.ps1 @@ -1,5 +1,16 @@ [CmdletBinding()] -param() +param( + # The account the task runs as. Defaults to the current user, but MUST be passed + # explicitly when launching this script elevated — if UAC is satisfied with a + # different admin account, $env:USERNAME inside the elevated process is that + # admin, not the intended owner, and the task would be registered for the wrong + # user (whose credential vault lacks the git remote's stored credential). + [string] $UserId = "$env:USERDOMAIN\$env:USERNAME", + + # Optional path to write a transcript of the result to, so a caller that cannot + # see the elevated console can read the outcome. + [string] $LogPath +) $ErrorActionPreference = 'Stop' $repositoryRoot = $PSScriptRoot @@ -19,7 +30,7 @@ $trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Sunday -At 10:00AM # cannot read it, so `git fetch origin main` fails and the whole sync aborts. # Interactive logon keeps access to that vault; StartWhenAvailable catches up a # missed run at the next logon. -$currentUser = "$env:USERDOMAIN\$env:USERNAME" +$currentUser = $UserId $principal = New-ScheduledTaskPrincipal -UserId $currentUser -LogonType Interactive -RunLevel Limited $settings = New-ScheduledTaskSettingsSet ` -StartWhenAvailable ` @@ -36,4 +47,16 @@ Register-ScheduledTask ` -Description 'Mirrors custom Microsoft Scout skills to PromptWorks.' ` -Force | Out-Null -Write-Host "Registered 'PromptWorks Weekly Skill Sync' to run as $currentUser, Sundays at 10:00 AM." +$msg = "Registered 'PromptWorks Weekly Skill Sync' to run as $currentUser, Sundays at 10:00 AM." +Write-Host $msg +if ($LogPath) { + $info = Get-ScheduledTask -TaskName 'PromptWorks Weekly Skill Sync' | Get-ScheduledTaskInfo + $task = Get-ScheduledTask -TaskName 'PromptWorks Weekly Skill Sync' + @( + "OK: $msg", + "RunAs : $($task.Principal.UserId)", + "LogonType: $($task.Principal.LogonType)", + "State : $($task.State)", + "NextRun : $($info.NextRunTime)" + ) | Set-Content -LiteralPath $LogPath -Encoding UTF8 +}