“The Term Is Not Recognized” in PowerShell: The Common Causes and Fixes

“The term ‘X’ is not recognized as the name of a cmdlet, function, script file, or operable program” means PowerShell looked for X everywhere it knows to look and found nothing. Run this to see what it can find for that name:

PowerShell
Get-Command X -All

Replace X with the name from your error. If it answers with the same “not recognized” error, work down the causes below. PowerShell 7 words the message slightly differently (“as a name of a cmdlet, function, script file, or executable program”); it is the same error.

PowerShell 7: notacmd not recognized, Get-Command notacmd giving the same error, git found on PATH, here.ps1 not recognized until it is run as .\here.ps1

A Typo

The first thing to rule out. Get-Foo-Bar and Get-FooBar are different commands. Tab completion avoids it, and Get-Command with wildcards finds a command from part of its name:

PowerShell
Get-Command *uptime*

A Script in the Current Folder Needs .\

PowerShell does not run things from the current folder unless you say so. A script called here.ps1 in the folder you are in fails, and .\here.ps1 works:

PowerShell
here.ps1      # The term 'here.ps1' is not recognized
.\here.ps1

If the path is right and it still fails with the .\ form, the file is not where you think. Check with Get-ChildItem.

A Path With Spaces

An unquoted path stops at the first space, so PowerShell looks for C:\Program and reports that as the unrecognized term. Quote the path and put & in front:

PowerShell
& "C:\Program Files\My Tool\tool.exe" --version

The Command Lives in a Module You Do Not Have

Many cmdlets are not built in. If the module is not installed, the cmdlet does not exist yet. Get-WUList is the example: it comes from the PSWindowsUpdate module. Install the module the command belongs to. Get-WUList comes from PSWindowsUpdate:

PowerShell
Find-Module -Name PSWindowsUpdate
Install-Module -Name PSWindowsUpdate -Scope CurrentUser

See Get-WUList Is Not Recognized: Install the PSWindowsUpdate Module for the full walkthrough. If the module is installed but still not found, Import-Module <name> loads it for the session.

A Program That Is Not on PATH

For an .exe or .cmd, PowerShell searches the folders in the PATH environment variable. If the program is installed but its folder is not in PATH, the name is not recognized. Check whether PowerShell can see it, and where it is looking:

PowerShell
Get-Command git -All | Select-Object Source
$env:PATH -split ';' 

A new install often adds itself to PATH, but terminals that were already open keep the old copy until you close and reopen them. If the folder is genuinely missing, add it: Add a Folder to PATH in Windows Permanently has the steps, this one does it for Claude Code, and How to Get and Set Environment Variables in PowerShell covers environment variables in general.

The Wrong PowerShell Version

Some commands exist only in PowerShell 7, and the blue Windows PowerShell 5.1 window will not recognize them. Get-Uptime is one: it does not exist in 5.1 and works in 7. Check which one you are in:

PowerShell
$PSVersionTable.PSVersion

See How to Check Your PowerShell Version ($PSVersionTable) and Install PowerShell 7 on Windows and Keep Windows PowerShell 5.1.

Why It Happens

When you type a name, PowerShell checks aliases, functions, cmdlets in loaded modules and files in the PATH folders. It does not look in the current folder unless you give a path. The message is what it says when all of those come up empty, so the cause is always that the name is wrong, or the thing is not installed, loaded or on PATH.

Common Questions

It works in one terminal but not another.

Each terminal reads PATH when it starts. Close it and open a new one. Also check you are in the same PowerShell version in both.

Does running as administrator fix it?

Almost never. It is a missing name, not a permission problem, and a permission problem gives a different error.

Do I get the same message for my own function?

Yes. If a script calls a function before it is defined, or one in another file you have not dot-sourced, you get the same error.

If SQL Server is part of your day job, my current work lives over at sqldba.blog: production DBA scripts, an error library and the SSMS guide.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *