Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install hyperv cmdlet on workstation

I have a script that starts new HyperV VM's on a remote server using powershell

New-VM
Get-VM

I want to run this script on my desktop, however I get the following error.

 the term 'new-vm' is not recognized as the name of a cmdlet

I can't figure out how to install the new-vm cmdlet on my workstation

Get-WindowsFeature
the target of the specified cmdlet cannot be a windows client-based operating system

Install-windowsFeature hyperv-
    the target of the specified cmdlet cannot be a windows client-based operating system

I am very new to powershell, and don't do much with windows.

How can I install the cmdlet New-VM on a Windows 8 machine?

Update

Also tried the following.

Enable-WindowsOptionalFeature -Online -FeatureName Hyper-V-Tools
Enable-WindowsOptionalFeature -Online -FeatureName Hyper-V-PowerShell

I see hyperv tools in the following command

Get-WindowsOptionalFeature -Online | sort state
Microsoft-Hyper-V
Microsoft-Hyper-V-Tools-All
Microsoft-Hyper-V-Management-Powershell

Update 2

I almost got it installed, but it gives this error:

PS C:\Windows\system32> Enable-WindowsOptionalFeature -online -FeatureName Microsoft-Hyper-V-Management-Powershell
Enable-WindowsOptionalFeature : One or several parent features are disabled so current feature can not be enabled.
At line:1 char:1
+ Enable-WindowsOptionalFeature -online -FeatureName Microsoft-Hyper-V-Management- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Enable-WindowsOptionalFeature], COMException
    + FullyQualifiedErrorId : Microsoft.Dism.Commands.EnableWindowsOptionalFeatureCommand

PS C:\Windows\system32>
like image 763
spuder Avatar asked Dec 24 '22 20:12

spuder


1 Answers

Got it installed. The powershell cmdlet has parents that can be installed by adding -all.

Enable-WindowsOptionalFeature -online -FeatureName Microsoft-Hyper-V-Management-Powershell -all

You will need to reboot before the cmdlet is available.

like image 137
spuder Avatar answered Jan 19 '23 06:01

spuder