microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
108.26k stars 6.39k forks source link

Can't set up "Command Not Found" feature #31196

Open DeFaLT-dj opened 6 months ago

DeFaLT-dj commented 6 months ago

Microsoft PowerToys version

v0.77.0

Installation method

Microsoft Store

Running as admin

Yes

Area(s) with issue?

Command not found

Steps to reproduce

I am trying to setup Command Not Found feature, but I get:

"EnableModule.ps1: Cannot dot-source this command because it was defined in a different language mode. To invoke this command without importing its contents, omit the '.' operator."

message at the Installation logs I have attached a video to show the process. As you can see from the video, I have both requirements checked

https://github.com/microsoft/PowerToys/assets/64617514/0831713f-4c0c-4d67-ba37-cf8af5c2d073

✔️ Expected Behavior

Command Not Found feature to be installed when hit Install button

❌ Actual Behavior

It opens a blank terminal window and just returns the error message mentioned above.

Other Software

No response

jaimecbernardo commented 6 months ago

Hi @DeFaLT-dj , what do you get when you open pwsh.exe yourself? Anything weird? What do you get if you run $ExecutionContext.SessionState.LanguageMode in pwsh.exe?

Wondering if this is a local administrative policy on your computer.

/needinfo

DeFaLT-dj commented 6 months ago

Hello. Yes, when I run it manually, it says "[Constrained Language Mode]" same thing that causes the issue. image

It is likely a policy I set back then to improve security, but I can't really remember where it was. If you know which policy is likely to limit this, please let me know

nguyen-dows commented 2 months ago

Hi @DeFaLT-dj, we just released the WinGet.CommandNotFound powershell module. We plan to deprecate this PowerToys utility soon.

Could you please install the WinGet.CommandNotFound module to see if you still have problems getting this to work for you?

If you run into any issues, can you run Install-PSResource -Name Microsoft.WinGet.CommandNotFound -Verbose and share the results?

Adding -Verbose will let us see all the logs related to this install operation.