Hi
I am trying to use the xHyper-v resource to run a simple configuraiton.
I keep getting this error when running Start-DscConfiguration “The PowerShell DSC resource MSFT_xVMSwitch does not exist at the PowerShell
module path nor is it registered as a WMI DSC resource.” When creating the MOF there is no error!!
However when I run get-module -listavailable it’s present. And when i run get-dscresoucre the xVMSwitch show thats its there as well
Heres the Config
Configuration MrHyperV_VM {
param (
[Parameter(Mandatory)]
[string]$VMName,
[Parameter(Mandatory)]
[string]$baseVhdPath,
[Parameter(Mandatory)]
[string]$ParentPath,
[Parameter(Mandatory)]
[string]$VMSwitchName
)
Import-DscResource -module xHyper-V
xVMSwitch switch {
Name = $VMSwitchName
Ensure = 'Present'
Type = 'Internal'
}
xVHD DiffVHD {
Ensure = 'Present'
Name = $VMName
Path = $baseVhdPath
ParentPath = $ParentPath
Generation = 'vhdx'
}
xVMHyperV CreateVM {
Name = $VMName
SwitchName = $VMSwitchName
VhdPath = Join-Path -Path $baseVhdPath -ChildPath "$VMName.vhdx"
ProcessorCount = 1
MaximumMemory = 2GB
MinimumMemory = 512MB
RestartIfNeeded = 'True'
DependsOn = '[xVHD]DiffVHD', '[xVMSwitch]switch'
State = 'Running'
Generation = 'vhdx'
}
}
MrHyperV_VM -VMName HCTest02 -baseVhdPath 'V:\VMs' -ParentPath "V:\VMs\VHDs\HCFil01.vhdx" -VMSwitchName 'ethernetSwitch'
Start-DscConfiguration -Wait -Path .\MrHyperV_VM -Verbose -Force
Im at a lost any help would be greatly appreciated