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>
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.
Related
I am trying to install Hyper V for an Azure Dev Ops (ADO) pipeline (using powershell task). When I do a "Get-VM", I am getting the typical powershell error "... not recognized as the name cmdlet" error so it make me believe Hyper V is not installed. When I do a "Get-Module -listavailable" Hyper V is not listed.
I have a build agent with Windows 2019 and Windows 2022 and neither seems to work.
I have tried the following;
DISM /Online /NoRestart /Enable-Feature /All /FeatureName:Microsoft-Hyper-V /LogLevel:4 <-- seems to work but at the end of the task it just says Exit 1
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -NoRestart -All
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Offline -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Online -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-Clients -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-PowerShell -NoRestart -All
import-module Hyper-V <-- says can't find module
I am stuck on what to do. I need Hyper V as part of my pipeline tests.
Thanks
Darren
I am afraid that Hyper V can't be enabled on Microsoft Hosted Agents. According to the documentation
Microsoft-hosted agents:
Run on Microsoft Azure general purpose virtual machines Standard_DS2_v2
Hyper V can only be enabled on Virtual Machines which supports Nested Virtualization. Check this link for more details:
https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/nested-virtualization
Unfortunately, DSv2-series do not support Nested Virtualization
Figured it out somewhat. Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All is sufficient to do it BUT a reboot is needed which is a new issue. Will follow up with that in a separate posting.
Receive the following error message when I run the Get-WindowsOptionalFeature command.
PS C:\Windows\system32> Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
Get-WindowsOptionalFeature : An error occured. No operation was performed.
Verify that DISM is installed properly in the image, and then try the operation again.
At line:1 char:1
+ Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-WindowsOptionalFeature], COMException
+ FullyQualifiedErrorId : Microsoft.Dism.Commands.GetWindowsOptionalFeatureCommand
Make sure your DISM is actually working with:
dism /online /Get-FeatureInfo /FeatureName:SMB1Protocol
Double-check that you have the correct version for your build of windows as well. Sometimes this can be caused if you have some other version of the WAIK installed for example:
gwmi win32_operatingsystem | fl *
caption : Microsoft Windows Server 2012 R2 Standard
BuildNumber : 9600
Version : 6.3.9600
dism /online /get-feature
Deployment Image Servicing and Management tool
Version: 6.3.9600.19408 # Version of dism
Image Version: 6.3.9600.19397 # Version of windows
I am unable to enable the optional feature IIS-ASPNET and IIS-ManagementConsole. I keep getting the below error
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 IIS-ASPNET
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Enable-WindowsOptionalFeature], COMException
+ FullyQualifiedErrorId : Microsoft.Dism.Commands.EnableWindowsOptionalFeatureCommand
What are the parent features of iis-aspnet and IIS-ManagementConsole that need to be enabled?
You need to pass the -All parameter to Enable-WindowsOptionalFeatures which installs the required parent features:
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET, IIS-ManagementConsole -All
To enable asp.net you also need to install the .net extensibility feature. you could try below PowerShell command:
Enable-WindowsOptionalFeature -Online -FeatureName IIS-NetFxExtensibility, IIS-NetFxExtensibility45,IIS-ASPNET, IIS-ASPNET45
To enable ManagementConsole you could use below command:
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ManagementConsole
We have a legacy windows project, that we would like to containerize.
This uses MSMQ multicasting (part of Telerik's obsolete ORM).
Inside my Windows Container, If I attempt
Enable-WindowsOptionalFeature -Oneline -FeatureName MSMQ-Multicast -All
This fails:
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 MSMQ-Multicast -Al ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Enable-WindowsOptionalFeature], COMException
+ FullyQualifiedErrorId : Microsoft.Dism.Commands.EnableWindowsOptionalFeatureCommand
Also:
PS C:\scripts> netcfg -c p -i ms_rmcast
Trying to install ms_rmcast ...
... failed. Error code: 0x800106d9.
The container is connected via a 'transparent' network type, so is bridged to the local network.
Is there any solution to this, or is this just not (yet) supported?
Is version 1809 likely to help?
Any other clever ideas?
MSMQ was added in 1803 SAC channel. It does not exist in LTSC channel.
https://blogs.technet.microsoft.com/virtualization/2018/07/25/hello-world-msmq-from-windows-containers/
I apologize if this is a NOOB question but I wrote a PowerShell script on my windows 10 box and I am trying to run the script on a 2008 box. On the new install of the 2008 box I had to add the windows powershell feature. My end goal is to install the Web Server (IIS) Administration Cmdlets
PS C:\Users\Administrator> Get-Module -ListAvailable | Import-Module
PS C:\Users\Administrator> Get-Module -ListAvailable
ModuleType Name ExportedCommands
---------- ---- ----------------
Manifest BitsTransfer {}
Manifest PSDiagnostics {Enable-PSTrace, Enable-WSManTrace, Start-Trace, Disable-PSWSManCombined...
PS C:\Users\Administrator>
PS C:\Users\Administrator> add-pssnapin WebAdministration
Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 2.
At line:1 char:13
+ add-pssnapin <<<< WebAdministration
+ CategoryInfo : InvalidArgument: (WebAdministration:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
PS C:\Users\Administrator>
PS C:\Users\Administrator> Import-Module WebAdministration
Import-Module : The specified module 'WebAdministration' was not loaded because no valid module file was found in any module directory.
At line:1 char:14
+ Import-Module <<<< WebAdministration
+ CategoryInfo : ResourceUnavailable: (WebAdministration:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId :Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Any ideas?
You need to install the IIS managment tools before the WebAdministration-module is available. Try (tested on Win10):
Enable-WindowsOptionalFeature -Online -FeatureName "IIS-WebServerManagementTools" -All
Windows Server 2008 doesn't come with a PowerShell module for managing IIS. That feature was added with Windows Server 2008 R2. You need to download and install it first. See here for further information. See also this related question.