Forum Discussion
Error while running New-VHD cmdlet on Windows Server 2019
Hi,
I am trying to create an empty .vhd file using the PowerShell cmdlet New-VHD on Windows Server 2019 virtual machine hosted on Hyper-V.
I am seeing the attached error while running the cmdlet:
I suspected that it could be related to Hyper-V role on the machine. But, it seems to be all good. Here is the screenshot of what I see on my machine.
Strangely I don't see the Hyper-V Services feature on the Windows Server 2019 VM that I am working on. I see Hyper-V Services feature on other VMs on the same Hyper-V for example Windows 10 VM.
Any help here will be greatly appreciated.
Thanks,
Yojana
1 Reply
New-VHD comes from the Hyper-V PowerShell module.
Check whether the cmdlet and module are installed:
Get-Command New-VHD -ErrorAction SilentlyContinue
Get-Module -ListAvailable Hyper-V
If the module is missing:
Install-WindowsFeature Hyper-V-PowerShell
Then reopen an elevated PowerShell session and test:
New-VHD -Path C:\VMs\Test.vhdx -Dynamic -SizeBytes 20GB
Make sure the destination folder exists and that your account has write permissions.
You don't need nested virtualization simply to create a VHD/VHDX file.