Reputation: 1
I'm looking for a way to be able to create a VHD via PowerShell.
It seems that the best approach is to create the VHD with the New-VHD command. Unfortunately, I am unable to load the module to access the New-VHD command.
I have copied the file “C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Hyper-V\2.0.0.0\Hyper-V.psd1” for this purpose and put it at the path mentioned above. When loading the module, I do not receive an error when I execute this via the following command:
Import-PowerShellDataFile “C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Hyper-V\2.0.0.0\Hyper-V.psd1”
I can access the command New-VHD via autocomplete after loading, but I get the error when executing:
The command “New-VHD” was found in the module “Hyper-V”, but the module could not be loaded. If you would like more information, run “Import-Module Hyper-V”.
If I now run
Import-Module Hyper-V”
I get the following error:
Import-Module : The module to be processed listed in the module manifest “C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Hyper-V\Hyper-V.psd1” in the “NestedModules” field
“Microsoft.HyperV.PowerShell.Cmdlets.dll” was not processed because no valid module was found in any module directory.
In line:1 Character:1
I tried to manually move the file “Microsoft.HyperV.PowerShell.Cmdlets.dll” to the Hyper-V modules folder, but this did not solve the problem.
Does anyone have an idea how I can access the Command New-VHD without activating the feature for this? Alternatively, does anyone have an idea how I can best create and mount a VHD via PowerShell?
Thank you in advance.
Used the commands above to manually import the psd1 to be able to access the command New-VHD
Upvotes: 0
Views: 118