The term ‘Get-VM’ is not recognized as the name of a cmdlet ( Easy Solution)

In this tutorial, we will learn How to fix the error “The term ‘Get-VM’ is not recognized as the name of a cmdlet“.

You might get the error “The term ‘Get-VM’ is not recognized as the name of a cmdlet“while trying to get the virtual machine details in Azure with the PowerShell command.

To solve the error ‘Get-VM’ is not recognized as the name of a cmdlet” follow the below steps :

  • Import the Hyper-V module using the cmdlet import-module Hyper-V .

Let’s go the steps in detail.

The term ‘Get-VM’ is not recognized as the name of a cmdlet (How to fix it )

What is Get-VM cmdlet ?

Get-VM

Get-VM is a useful PowerShell cmdlet to get the list of virtual machines .

Following is the Syntax for get-VM

Syntax

Get-VM
 [[-Name] <String[]>]
[-CimSession <CimSession[]>]
[-ComputerName <String[]>]
[-Credential <PSCredential[]>]
[<CommonParameters>]

Example: Simply type Get-VM in Windows PowerShell as shown below.

PS C:\WINDOWS\system32> Get-VM

This command will help you to get the list of virtual machines from your local virtual machine Host.

Additional syntax for GetVM

Get-VM
 [-CimSession <CimSession[]>]
 [-ComputerName <String[]>]
 [-Credential <PSCredential[]>]
 [[-Id] <Guid>]
 [<CommonParameters>]

For example

 Get-VM -ComputerName MyNewVM | Where-Object {$_.State -eq 'Running'}

The above shown example will help you to get the list of all the Virtual Machine with “Running Status” on the Hyper-V host MyNewVM .

How to fix the errors ? ( Solution )

Let’s try to execute Get-Vm in PowerShell and see what we get as output.

Get-Vm
The term 'Get-VM' is not recognized
Error :
Get-Vm : The term 'Get-Vm' 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
+ Get-Vm
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-Vm:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

To solve the above error follow the below steps :

Step 1: We need to import the Hyper-V module

import-module Hyper-V

As we try to import the Hyper-V module with the import-module Hyper-V module we get a new error. Common not again🙄, Don’t worry we will fix this as well 😀

Complete error

import-module : The specified module 'Hyper-V' was not loaded because no valid module file was found
in any module directory.
At line:1 char:1
+ import-module Hyper-V
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (Hyper-V:String) [Import-Module], FileNotFoundExce
   ption
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleComman
   d

Follow the below steps to fix the above-mentioned error.

Step 1: Go to Control panel –>Programs –> Program and features –> Turn Windows features on or off

Search for Control Panel in the Windows Search Box

Open the Control Panel app

Now Click on Programs

Under Programs and features Click on “Turn Windows features on or off

#A quick way to access “Turn Windows features on or off

  • Press Windows+R Key
  • Type optionalfeatures in the Run Dialog box

Step 2: Under Windows Features ensure the Hyper-V module is checked.

Under Windows, features check for the module Hyper-V and select it is not selected and Press OK

Click on OK and restart the system for the changes to take effect.

You can verify the module by navigating the below path. Visit the below path and ensure the Hyper-V directory exists under Modules

C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Hyper-V

Once the Hyper-V module is installed and we execute the command “Get-Vm” via PowerShell we don’t get the error anymore.

Other FAQs

Get-vm object not found

If you get error the get-vm object not found then go through the below checklist .

  1. Ensure that the Windows PowerShell or PowerShell ISE is running with admnistrator user id .If not then right click and start PowerShell with run as administrator option .
  2. Make sure your are running the Latest version of PowerShell
  3. Install the Hyper-V PowerShell Module as mentioned in the previous step by step Solution.
  4. Ensure the Hyper-V module is imported using the following PowerShell cmdlet.
Import-Module Hyper-V

We hope this tutorial on The term ‘Get-VM’ is not recognized as the name of a cmdlet was helpful.

Related articles :

The term Get-AzureAccount is not recognized error: How to fix it

How to fix Because of Protocol Error Code 0x112d ( Easy Guide)

AZ-120 Exam Study Guide 2021(Planning and Administering Microsoft Azure for SAP Workloads)

How to Check Azure Credit ( Easy Guide )