Working in the command line often involves trying to execute familiar utilities—such as htop, jq, git-lfs, or ffmpeg—only to encounter the frustrating shell error: “The term is not recognized as the name of a cmdlet, function, script file, or operable program.” In Linux distributions like Ubuntu, the shell automatically detects missing packages and suggests the exact apt install command. Microsoft brings this exact capability to Windows 11 through the Command Not Found module in Microsoft PowerToys. By integrating with PowerShell 7 and the Windows Package Manager (winget), Command Not Found instantly detects mistyped or missing binaries and offers a one-click installation prompt. This guide explains how to enable and configure this feature in Windows 11.
How the Command Not Found Module Works
The Command Not Found utility hooks into the PowerShell execution pipeline via an official PowerShell feedback provider:
- When you enter a command that Windows cannot locate in your system
PATH, the module intercepts the command failure event. - It queries the official winget package database in real time to locate software packages that provide a binary with that exact executable name.
- If a matching package is discovered, PowerShell displays an interactive prompt showing the package name, publisher, version, and the exact
winget installcommand required.
Prerequisites for Enabling Command Not Found
Because the feedback provider architecture requires modern PowerShell APIs, Command Not Found has two specific prerequisites:
- PowerShell 7.4 or Later: The legacy built-in Windows PowerShell 5.1 does not support feedback providers. You must install modern PowerShell 7.
- Microsoft PowerToys (v0.75 or Later): Ensure you have an updated version of PowerToys installed.
Installing Prerequisites via Winget
If you do not already have PowerShell 7 or PowerToys installed, open Windows Terminal and run:
winget install --id Microsoft.PowerShell --source winget
winget install --id Microsoft.PowerToys --source winget
Step 1: Enabling the Module in PowerToys Settings
- Open the PowerToys application from your Start menu or system tray.
- In the left sidebar, scroll down to the System Tools group and click Command Not Found.
- Toggle the switch next to Enable Command Not Found to On.
- Review the status indicator. If PowerShell 7 is detected, PowerToys will indicate that the module is ready for registration.
Step 2: Registering the PowerShell Feedback Provider
To link the PowerToys module into your PowerShell terminal session, you must import the module into your user profile:
- Open Windows Terminal and launch a PowerShell 7 (pwsh) tab (ensure the tab header shows PowerShell 7, not Windows PowerShell).
- Install the official PowerShell feedback provider module from the PowerShell Gallery by executing:
Install-Module -Name Microsoft.WinGet.CommandNotFound -Scope CurrentUser -Force - To ensure the module loads automatically every time you open a terminal window, add it to your permanent profile script. Open your profile in Notepad:
notepad $PROFILEIf prompted that the file does not exist, click Yes to create it.
- Add the following line to the end of the profile document:
Import-Module -Name Microsoft.WinGet.CommandNotFound - Save the file (Ctrl + S) and close Notepad.
- Reload your current session to apply the changes immediately:
. $PROFILE
Testing Command Not Found in Action
To verify that the integration functions correctly, test an uninstalled command. For example, attempt to run the popular JSON processor jq or the file search utility ripgrep:
jq --version
Instead of a standard red error message, PowerShell displays an intelligent suggestion block:
Command 'jq' not found, but can be installed with:
winget install --id jqlang.jq
You can simply copy the suggested winget command and press Enter. Once the installation completes, the command becomes immediately usable in subsequent terminal sessions.
Advanced Customisation and Performance Settings
You can fine-tune how Command Not Found behaves within PowerToys settings:
- Cache Management: PowerToys caches package index catalogs locally to ensure instant suggestions without introducing latency to terminal responsiveness. You can force an index update directly within the PowerToys settings panel.
- Excluding Specific Shells: If you use multiple command environments (such as Command Prompt or Git Bash), remember that Command Not Found operates specifically within PowerShell 7 sessions.
- Feedback Provider Priority: In PowerShell 7, you can run
Get-PSReadLineOptionto adjust predictor and suggestion display colours to match your terminal theme.