PowerShell errors: Dealing with ‘term is not recognized as the name of a cmdlet’

As someone who has written numerous articles about Microsoft PowerShell for TechGenix, I often have people tell me that they find PowerShell to be intimidating because when things go wrong the error messages can be cryptic and unhelpful. As such, I wanted to take the opportunity to talk about some underlying causes of what is perhaps the most common of all PowerShell errors.

‘Term not recognized’

The simplest and yet one of the most common of all PowerShell errors states that a term is not recognized as the name of a cmdlet, function, script file, or operable program. The error goes on to say that you should check the spelling of the name, or if a path was included to verify that the path is correct and try again. You can see an example of this error in the figure below.

powershell error: term is not recognized as the name of a cmdlet

Spelling errors

There are three main causes for this error (and several other causes related to the three main causes). As you may have already gathered, the most common cause is simply misspelling the name of the cmdlet. (This is, obviously, one of the main causes for all PowerShell errors.) In the screen capture, for instance, I intentionally misspelled the Get-Help cmdlet. As such, if you get this particular error, then you should always begin the troubleshooting process by checking your spelling.

Path errors

A second reason why this error message happens is because you are using an incorrect path. On my computer, for example, I have a folder named C:\Scripts, and that folder contains a number of different PowerShell scripts, including a script called Calendar.ps1 that displays a graphical calendar that was created using PowerShell. If I were to navigate to the C:\Scripts folder and launch the calendar script, then the script runs as expected. If I try executing the script from the root folder (without specifying a path), however, then I receive an error message as shown below.

powershell errors

 

Keep in mind that the same thing can also happen if you try to call an external function without specifying a path. Speaking of functions, there are situations in which a call to a function can trigger this error, even if the function exists in the same script. This happens when you misspell the function name or try to call a function that exists in a different scope. An easy (although sometimes frowned upon) way of making this problem go away is to make the function global by adding the word global to the function name. Suppose, for instance, that you currently have a function named Test that looks like this:


Function Test($X)
{
//
}


Here is what it would look like if you made the function global:


Function global:Test($x)
{
//
}


Missing modules

The third cause of this error is the failure to load a required module. In PowerShell, modules are collections of cmdlets that extend PowerShell’s functionality. In most cases, the cmdlets contained within a module are related to a specific product or to a specific Windows role or feature. For example, a module might contain cmdlets related to Microsoft Azure, Hyper-V, Active Directory, or even Exchange Server.

In any case, you won’t be able to run a non-native PowerShell cmdlet unless the module that defines that cmdlet is loaded first. Windows itself includes a lot of modules that provide PowerShell cmdlets for non-default Windows features such as Hyper-V or Active Directory. Newer versions of PowerShell will load these modules automatically on an as-needed basis, whereas older PowerShell versions require you to explicitly load the required modules. Modules containing non-native cmdlets will almost always have to be loaded manually.

To see what modules look like and how they work, check out the screen capture below. The first thing that I am doing is using the Get-Module cmdlet to show a list of the modules that are currently loaded. In this case, there are three modules loaded. The Get-Module cmdlet shows you the names of each module, and the cmdlets that the module contains.

powershell errors

The next thing that I did was to run the Get-VM cmdlet. This is a Hyper-V specific cmdlet that is not included in the default Windows cmdlet set. Notice that the cmdlet completed successfully. This happened because I am working from a newer version of Windows and because the Get-VM cmdlet is native to Windows, even though the corresponding module is not loaded by default. In case you are wondering, the Get-VM cmdlet displays the names of the Hyper-V virtual machines that exist on the server. Of course, the cmdlet’s function is irrelevant to this discussion, since I wanted to focus primarily on error resolution.

My last step was to run the Get-Module cmdlet one more time. This time, the Hyper-V module is included among the list of modules that are loaded into Windows. Because the module has been imported, I am free to run any of the Hyper-V specific cmdlets that are included in the module. Granted, Windows loaded this module for me automatically, but the same basic principle also applies to third-party modules that you have to load manually.

If you ever do need to manually import a module in order to run a PowerShell cmdlet, you can do so by using the Import-Module cmdlet, followed by the name of the module that contains the cmdlet that you want to run. Keep in mind that the module only remains in place for the duration of your PowerShell session. If you want to use the cmdlet again at a different time, you will need to import the module again.

PowerShell errors: Many causes

Among PowerShell errors, term not recognized is commonly dismissed as a spelling error, but there can be so many other causes beyond just a misspelled cmdlet. Path errors, incorrect function scopes, and missing modules can all sometimes cause this error to occur.

Photo credit: Shutterstock

23 thoughts on “PowerShell errors: Dealing with ‘term is not recognized as the name of a cmdlet’”

  1. I have been trying to figure out how to modify the default start menu – and in the process, I think I screwed up my computer (accidentally applied it via GPO).

    Basically, I am trying to issue the ps command “Import-StartLayout” and am getting the dreaded “The term ‘Import-startlayout’ is not recognized as the name of a cmdlet”.

    So where/how do I re-enable this applet?

  2. trying to find hash for multiple files. Is there a way to do that? Tried using
    ” md5sum * >checklist.chk ” but getting the above error. I am on the same path..where files are. But my extension of file is .atmx and file name is “AcctAnalysisAdd”

  3. md5sum is not a PowerShell command. That’s why you are getting the error. PowerShell commands are made up of two words. There is a verb, a dash, and a noun (such as Get-Hash, although Get-Hash is not a real command). My advice would be to do a quick Web search on PowerShell file hash. There are a number of freely available scripts that have been developed for the purpose of retrieving an MD5 hash.

  4. Is it possible to call a script to run another script? I have 2 files in the same directory (main.ps1, utils.ps1). If I call main.ps1 it gives the error “the name is not a cmdlet, function…”

  5. Hi Will,
    There are two things that are wrong with the command that you are using. First, it’s Install-WindowsFeature, not Add-WindowsFeature. Second, there is no space after the dashes (“Windows-Server-Backup” as opposed to “Windows- Server- Backup”). In that doesn’t work for you, then try adding -Name before Windows-Server-Backup.
    Good Luck,
    Brien

  6. Thanks so much!
    You mentioned a spelling error and something so simple fixed my problem.

    My path was originally C:\Users\Cameron\Desktop\ATLAS SERVER\ATLAS

    I changed it to C:\Users\Cameron\Desktop\ATLAS_SERVER\ATLAS

    Adding an underscore in place with the space in the folder name fixed my issue

  7. I am creating boot.properties file inside my directory Oracle\Weblogic_Middleware\user_projects\domains\Domain1\servers\ManagedServer_1\security\ byt passing command “vi boot.properties” but I’m getting below error:
    PS C:\Oracle\Weblogic_Middleware\user_projects\domains\Domain1\servers\ManagedServer_1\security> vi boot.properties
    vi : The term ‘vi’ 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 line:1 char:1
    + vi boot.properties
    + ~~
    + CategoryInfo : ObjectNotFound: (vi:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Kindly help here.

  8. VI definitely isn’t a PowerShell command. PowerShell cmdlets consist of two words, seperated by a dash (example: get-VM). VI might be a Linux command, but I’m not sure.

  9. I am trying to run my c++ code on vs code but it is showing this error
    PS E:\cpp\welcome> .\v.exe
    .\v.exe : The term ‘.\v.exe’ 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 line:1 char:1
    + .\v.exe
    + ~~~~~~~
    + CategoryInfo : ObjectNotFound: (.\v.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

  10. Hi, thanks for the info. Unfortunately, the first two issues didn’t pertain to me, and when I try the third I get the dreaded “term is not recognized error” when I do Get-VM. Do you know any other possible way around this?

    For context I am using Anaconda on Windows 10 and I’m trying to use the package Nco specific to Python. Any help is appreciated, and thank you in advance!

  11. If you are getting this error while trying to use the Get-VM cmdlet, it means that the Hyper-V module is not installed.

  12. \ : The term ‘\’ 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 line:1 char:1
    + \
    + ~
    + CategoryInfo : ObjectNotFound: (\:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    When i try to excuete the powershell script, Kindly help me to overcome this error.

  13. PS C:\Windows\system32> choco install awscli -y -f
    Chocolatey v0.10.15
    Installing the following packages:
    awscli
    By installing you accept licenses for the packages.

    awscli v2.1.10 (forced) [Approved]
    awscli package files install completed. Performing other installation steps.
    ERROR: This package does not support 32 bit architecture.
    The install of awscli was NOT successful.
    Error while running ‘C:\ProgramData\chocolatey\lib\awscli\tools\chocolateyinstall.ps1’.
    See log for details.

    Chocolatey installed 0/1 packages. 1 packages failed.
    See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

    Failures
    – awscli (exited -1) – Error while running ‘C:\ProgramData\chocolatey\lib\awscli\tools\chocolateyinstall.ps1’.
    See log for details.
    PS C:\Windows\system32> log
    log : The term ‘log’ 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 line:1 char:1
    + log
    + ~~~
    + CategoryInfo : ObjectNotFound: (log:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    can anyone please solve it.

  14. I am currently making a discord bot using discord.js and visual studio code.
    I installed node and made sure to include the node module folder in the studio visual code, however upon trying to run my bot it say The term ‘note’ 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 agai

  15. If you run in 7.1:

    Clear-RecycleBin -Force

    directly, it works. If you add it to a function and call that function it doesn’t work. There is no path to go with it as that is supposed to clean all recycle bins.

    I declare paths as variables in the main window and just run the function with that variable and get the cmdlet error. Remove code from function back into the main script window and it works.

  16. Im running a Windows 2019 Datacenter (Desktop edition) VM and im unable to Install Windows Features Through powershell ISE 86 Using

    “Install-WindowsFeature AD-Domain-Services -IncludeManagementTools”

    And

    “Install-ADDSForest -DomainName “DigiTech.com” -DomainNetBiosName “DigiTech” -InstallDns:$true”

    the Error is The term install WindowsFeature is not recognized as the name of the CMDlet.

Leave a Comment

Your email address will not be published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top