{"record":{"id":"e5493c1f4f39ebbb","repo":"chenhg5/cc-connect","slug":"powershell-exe-not-found-windows-task-scheduler-m","errorCode":null,"errorMessage":"powershell.exe not found: Windows Task Scheduler management requires PowerShell","messagePattern":"powershell\\.exe not found: Windows Task Scheduler management requires PowerShell","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"daemon/windows.go","lineNumber":35,"sourceCode":"\twindowsTaskName   = ServiceName\n\twindowsScriptName = \"cc-connect-daemon.ps1\"\n)\n\nvar runPowerShell = func(script string) (string, error) {\n\tcmd := exec.Command(\"powershell.exe\", \"-NoProfile\", \"-NonInteractive\", \"-Command\", strictPowerShell(script))\n\tout, err := cmd.CombinedOutput()\n\treturn strings.TrimSpace(string(out)), err\n}\n\nfunc strictPowerShell(script string) string {\n\treturn \"$ErrorActionPreference = 'Stop'\\n\" + script\n}\n\ntype schtasksManager struct{}\n\nfunc newPlatformManager() (Manager, error) {\n\tif _, err := exec.LookPath(\"powershell.exe\"); err != nil {\n\t\treturn nil, fmt.Errorf(\"powershell.exe not found: Windows Task Scheduler management requires PowerShell\")\n\t}\n\treturn &schtasksManager{}, nil\n}\n\nfunc (*schtasksManager) Platform() string { return \"schtasks\" }\n\nfunc (m *schtasksManager) Install(cfg Config) error {\n\tif err := os.MkdirAll(DefaultDataDir(), 0755); err != nil {\n\t\treturn fmt.Errorf(\"create data dir: %w\", err)\n\t}\n\tif err := os.MkdirAll(filepath.Dir(cfg.LogFile), 0755); err != nil {\n\t\treturn fmt.Errorf(\"create log dir: %w\", err)\n\t}\n\n\tscriptPath := windowsTaskScriptPath()\n\t// 0644 has weak semantics on Windows; the file ACL is what matters.\n\t// We still write 0600 so the file's POSIX bits do not advertise read\n\t// access, and rely on the user's own profile ACLs for primary defense","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/daemon/windows.go#L17-L53","documentation":"On Windows, cc-connect manages the daemon through Windows Task Scheduler driven by PowerShell (schtasksManager). newPlatformManager probes for powershell.exe via exec.LookPath and returns this error if it is absent, because every Task Scheduler operation in the manager shells out to PowerShell. No Manager is returned, so all daemon subcommands fail.","triggerScenarios":"`cc-connect daemon install` on Windows when powershell.exe is not on PATH — e.g. PATH missing System32\\WindowsPowerShell\\v1.0\\, PowerShell removed by hardening policies, or running under an environment with a stripped PATH (some services/ssh sessions).","commonSituations":"Minimal Windows Server installs with PowerShell features removed; custom PATH configured without system paths; running cc-connect from a service account whose PATH differs from the interactive user's; Windows Nano Server without full PowerShell.","solutions":["Restore powershell.exe to PATH: ensure `C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\` is in the PATH of the account running cc-connect","Verify with `where.exe powershell.exe` in the same shell/session that runs cc-connect","Reinstall/enable Windows PowerShell via 'Turn Windows features on or off' or `Add-WindowsCapability -Online -Name Microsoft.Windows.PowerShell*`","If PowerShell is deliberately absent, manage cc-connect with nssm or a Windows service wrapper instead of `cc-connect daemon`"],"exampleFix":"// before (PowerShell missing from PATH)\n$ cc-connect daemon install\n// error: powershell.exe not found\n// after (PowerShell)\n$ setx PATH \"$env:PATH;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\\"\n# reopen the shell, then\n$ cc-connect daemon install","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"powershell.exe\"); err != nil {\n    log.Fatal(\"powershell.exe not on PATH; add C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\ to PATH before running daemon install\")\n}\ncc-connect daemon install","typeGuard":null,"tryCatchPattern":"if err := daemon.Install(cfg); err != nil && strings.Contains(err.Error(), \"powershell.exe not found\") {\n    return fmt.Errorf(\"install PowerShell or manage cc-connect with nssm instead: %w\", err)\n}","preventionTips":["Verify `where.exe powershell.exe` succeeds in the exact account/session that will run cc-connect (service accounts may have different PATHs)","Never remove C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\ from system PATH on hosts running cc-connect","On hardened Nano Server/minimal images, confirm PowerShell capability is installed before enabling daemon management","If PowerShell is intentionally absent, provision nssm or a service wrapper as the standard cc-connect supervisor"],"tags":["daemon","windows","powershell","path","task-scheduler"],"backgroundTag":"command-not-found","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}