Skip to content

Powershell completion script results in CommandNotFoundException #1566

@pem884

Description

@pem884

Summary

Following the instructions for enabling Powershell shell completions, I ran Add-Content -Path $PROFILE -Value '(COMPLETE=powershell prek) | Out-String | Invoke-Expression'. This did what I expected it to: it added a line to my $PROFILE, (COMPLETE=powershell prek) | Out-String | Invoke-Expression.

However, also as expected, that line results in this error when the profile loads (and, indeed, if one types that string at the prompt:

COMPLETE=powershell : The term 'COMPLETE=powershell' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\Patrick\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:357 char:2
+ (COMPLETE=powershell prek) | Out-String | Invoke-Expression
+  ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (COMPLETE=powershell:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

If the problem isn't apparent, perhaps someone can tell me what it's designed to do so I can help? As a user of both Powershell & unix shells, I wasn't able to figure out what the command is that we want Powershell to run after glancing at some of the other completion scripts.

Platform

Windows 10 x86_64

Version

prek 0.3.1 (bc142a2 2026-01-31)

.pre-commit-config.yaml

not relevant

Log file

2026-02-05T03:33:51.720707Z DEBUG prek: 0.3.1 (bc142a2 2026-01-31)
2026-02-05T03:33:51.720806Z DEBUG Args: ["c:\users\username \.local\bin\prek.exe"]
2026-02-05T03:33:51.803464Z TRACE get_root: close time.busy=82.6ms time.idle=5.10µs

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions