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

In this azure tutorial, we will discuss how to fix the error, The term ‘Get-VM’ is not recognized as the name of a cmdlet. which comes while trying to get the VM details using PowerShell.

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

Recently while trying to execute Get-VM PowerShell command, I got the above error message

Get-VM
The term 'Get-VM' is not recognized as the name of a cmdlet
“The term ‘Get-VM’ is not recognized as the name of a cmdlet.”

the complete error message is

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:3 char:1

  • Get-VM
  • ~~
    • CategoryInfo : ObjectNotFound: (Get-VM:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException

The term ‘Get-VM’ is not recognized as the name of a cmdlet [Solved]

To fix this error you need to follow the below steps.

Step-1:

Import the Hyper-V module

import-module Hyper-V 

After executing the above command i got the below error

The specified module 'Hyper-V' was not loaded
hyper is not recognized

The error is

import-module : The specified module ‘Hyper-V’ was not loaded because no valid module file was found in any module directory.

import-module: The specified module ‘Hyper-V’ was not loaded because no valid module file was found in any module directory.[Solved]

To fix this error, You need to to follow the below steps

Step-1:

Open the control panel –>Programs –> Program and features –> Turn Windows features on or off

The specified module 'Hyper-V' was not loaded
the term ‘get-vm’ is not recognized as the name of a cmdlet

Step-2:

Check the Hyper-V modules like below and click on the OK button,

The specified module 'Hyper-V' was not loaded because no valid module file was found in any module directory
Powershell “Get-VM” error

Step-3:

This will search for the files and will apply the changes.

The specified module 'Hyper-V' was not loaded because no valid module file was found
get-vm not recognized

Step-4:

Now the changes have been added successfully. It will ask to restart, click on the Restart now button to finish the installation.

The specified module 'Hyper-V' was not loaded because no valid module file was found
get-vm – wasn’t recognized as name of cmdlet

Note: Unless and until you restart the system the changes will not affected. So click on the Restart now button to restart.

Now to verify the modules are installed properly, Go to the below path and see if the Hyper-V module is present there now.

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

the term 'get-vm' is not recognized
The Get-VM is not recognized as a command after taking a session

Now if you will try to execute the below command, It will not throw any error

Get-VM 

Install Hyper-V PowerShell

Well, let’s discuss how to install Hyper-V PowerShell module on different operating systems.

How to Install the Hyper-V PowerShell Module using PowerShell

There are multiple ways to install the Hyper-V PowerShell Module, but one of the easiest ways to install the Hyper-V PowerShell module is by using PowerShell.

Installing the Hyper-V PowerShell Module in Windows Server 2012, 2016, and 2019 using PowerShell

Make sure, you are running a Windows Server 2012, 2016 or 2019 operating system. Now follow the below steps

  • Open the PowerShell ISE as Run as Administrator mode.
  • Now, run the below PowerShell cmdlet to see all the related tools.
PS C:\WINDOWS\system32> Get-WindowsFeature *hyper-v*
  • You can run the below PowerShell cmdlet, if you want to install only the PowerShell module.
PS C:\WINDOWS\system32> Install-WindowsFeature -Name Hyper-V-PowerShell
  • If you want to install both the Hyper-V Manager and the PowerShell module, then you can use the below PowerShell cmdlet.
PS C:\WINDOWS\system32> Install-WindowsFeature -Name RSAT-Hyper-V-Tools
  • In case, you want to install the Hyper-V hypervisor and all tools, then you can use the below PowerShell cmdlet.
PS C:\WINDOWS\system32> Install-WindowsFeature -Name Hyper-V -IncludeManagementTools

or, you can also use the below PowerShell cmdlet to install the Hyper-V hypervisor and all tools.

PS C:\WINDOWS\system32> Install-WindowsFeature -Name Hyper-V, RSAT-Hyper-V-Tools

This is how to Install the Hyper-V PowerShell Module in Windows Server 2012, 2016, and 2019 using PowerShell.

Installing the Hyper-V PowerShell Module in Windows Server 2012, 2016, and 2019 using Server Manager

Follow the below steps to install the Hyper-V PowerShell Module in Windows Server 2012, 2016, and 2019 using Server Manager.

  1. The first step is open the Add Roles and Features wizard and proceed to the Features page.
  2. Go to the Remote Server Administration Tools -> then Role Administration Tools -> expand the Hyper-V Management Tools and finally, check Hyper-V Module for Windows PowerShell.
  3. Click on the Install button and follow the wizard to complete the installation.
get-vm - wasn't recognized as name of cmdlet
The Get-VM is not recognized as a command

This is how to Install the Hyper-V PowerShell Module in Windows Server 2012, 2016, and 2019 using Server Manager

Installing the Hyper-V PowerShell Module in Windows 10 using PowerShell

You can able to install the Hyper-V PowerShell Module easily in Windows 10 using PowerShell.

The first thing is, you can run the below PowerShell cmdlet to see all the list of related features for Windows 10.

PS C:\WINDOWS\system32> Get-WindowsOptionalFeature -Online -FeatureName *hyper-v* | select DisplayName, FeatureName

Once you will run the above PowerShell cmdlet, you will get the below output

DisplayName                           FeatureName                            
-----------                           -----------                            
Hyper-V                               Microsoft-Hyper-V-All                  
Hyper-V Platform                      Microsoft-Hyper-V                      
Hyper-V Management Tools              Microsoft-Hyper-V-Tools-All            
Hyper-V Module for Windows PowerShell Microsoft-Hyper-V-Management-PowerShell
Hyper-V Hypervisor                    Microsoft-Hyper-V-Hypervisor           
Hyper-V Services                      Microsoft-Hyper-V-Services             
Hyper-V GUI Management Tools          Microsoft-Hyper-V-Management-Clients   
Powershell GET-VM not working
Powershell “Get-VM” error
  • You can run the below PowerShell cmdlet to install only the PowerShell module
PS C:\WINDOWS\system32> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-PowerShell
  • If you wish to install the Hyper-V management tool pack, you can use the below PowerShell cmdlet
PS C:\WINDOWS\system32> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Tools-All
  • Finally, if you want to install the entire Hyper-V stack, you can use the below PowerShell cmdlet
PS C:\WINDOWS\system32> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All

This is how to Install the Hyper-V PowerShell Module in Windows 10 using PowerShell.

Installing the Hyper-V PowerShell Module in Windows 10 using GUI

We have already discussed the steps to install the Hyper-V PowerShell module in Windows 10 using GUI. Check out the above steps for more information.

Get-vm object not found

If you facing the get-vm object not found error then you can check out a few suggestions as below.

  1. The first thing is, Make sure to run the Windows PowerShell or PowerShell ISE with Run as administrator mode.
  2. You must install the Hyper-V PowerShell Module using any of the approaches explained above.
  3. Make sure to import the Hyper-V module using the below PowerShell cmdlet.
Import-Module Hyper-V

Get-VM

Get-VM is an excellent PowerShell cmdlet to retrieve the list of virtual machines you have. The syntax for Get-VM is as below.

Syntax

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

Example: As an example, run the below PowerShell cmdlet.

PS C:\WINDOWS\system32> Get-VM

This helps you to retrieve the list of virtual machines on your local virtual machine host.

Another syntax is as below

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

Consider an Example as below

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

The above example helps you to retrieve all the VMs on the Hyper-V host MyNewVM those status is “Running”.

gets all virtual machines on Hyper-V host Server1 that are running

You may like following Azure tutorial:

In this tutorial, we discussed how to fix the error,  The term ‘Get-VM’ is not recognized as the name of a cmdlet, Install Hyper-V PowerShell, How to Install the Hyper-V PowerShell Module using PowerShell, Installing the Hyper-V PowerShell Module in Windows Server 2012, 2016, and 2019 using Server Manager, Installing the Hyper-V PowerShell Module in Windows 10 using GUI.

The above information will also fix the below issues

  • get-vm not recognized
  • get-vm is not recognized as the name of a cmdlet
  • the term ‘get-vm’ is not recognized as the name of a cmdlet
  • powershell get-vm not recognized
  • get-vm command not found
  • get-vm is not recognized
  • Powershell GET-VM not working
  • Get-vm object not found
  • Get-VM

I hope it helped you to fix your issue.