-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
Problem description
I am writing a DSC v3.0 configuration file (YAML) to provision a new Hyper-V VM but when I run it, I receive the error Exception: Hyper-V was unable to find a virtual machine with name "<machine name>"
Verbose logs
2025-10-14T11:07:04.180318Z ERROR PID 17192: Exception: Hyper-V was unable to find a virtual machine with name "SSRSDDCM101".
2025-10-14T11:07:04.211292Z ERROR Error: Command: Resource 'powershell' [exit code 1] manifest description: Error
DSC configuration
# =========================
# VM: SSRSDDCM101
# =========================
# Wiki: https://github.com/dsccommunity/HyperVDsc/wiki/Vhd
- name: SSRSDDCM101_Disk_OS
type: HyperVDsc/VHD
properties:
Name: SSRSDDCM101_OS.vhdx
Path: 'D:\Hyper-V\Virtual Hard Disks'
Generation: Vhdx
Type: Dynamic
MaximumSizeBytes: 68719476736 # 64GB in bytes (UInt64)
Ensure: Present
- name: SSRSDDCM101
type: HyperVDsc/VMHyperV
properties:
Name: SSRSDDCM101
Ensure: Present
Generation: 2
Path: 'D:\Hyper-V'
VhdPath: 'D:\Hyper-V\Virtual Hard Disks\SSRSDDCM101_OS.vhdx'
StartupMemory: 8589934592 # 8GB in bytes (UInt64)
ProcessorCount: 2 # UInt32
dependsOn:
- HyperVDsc/VHD::SSRSDDCM101_Disk_OS
- name: SSRSDDCM101_NIC_Network_Adapter
type: HyperVDsc/VMNetworkAdapter
properties:
Id: SSRSDDCM101-NIC
Name: Network Adapter
VMName: SSRSDDCM101
SwitchName: MGMTSwitch
Ensure: Present
dependsOn:
- HyperVDsc/VMHyperV::SSRSDDCM101
- name: SSRSDDCM101_MemoryAdv
type: PSDesiredStateConfiguration/Script
properties:
GetScript: |
@{ Result = 'VMMemory' }
TestScript: |
$vm = Get-VM -Name 'SSRSDDCM101' -ErrorAction SilentlyContinue
if (-not $vm) { return $false }
$m = Get-VMMemory -VMName 'SSRSDDCM101'
if ([bool]$m.DynamicMemoryEnabled -ne $true) { return $false }
if ($true) {
if (([UInt64]$m.MinimumBytes -ne [UInt64]4294967296) -or
([UInt64]$m.MaximumBytes -ne [UInt64]12884901888) -or
([int]$m.Buffer -ne 20) -or
([int]$m.Priority -ne 50)) { return $false }
}
return $true
SetScript: |
Set-VMMemory -VMName 'SSRSDDCM101' -DynamicMemoryEnabled $true -MinimumBytes 4294967296 -MaximumBytes 12884901888 -Buffer 20 -Priority 50
dependsOn:
- HyperVDsc/VMHyperV::SSRSDDCM101
- name: SSRSDDCM101_Disk_TEMP
type: HyperVDsc/VHD
properties:
Name: SSRSDDCM101_TEMP.vhdx
Path: 'D:\Hyper-V\Virtual Hard Disks'
Generation: Vhdx
Type: Dynamic
MaximumSizeBytes: 68719476736 # 64GB in bytes (UInt64)
Ensure: Present
- name: SSRSDDCM101_Attach_TEMP
type: HyperVDsc/VMHardDiskDrive
properties:
VMName: SSRSDDCM101
Path: 'D:\Hyper-V\Virtual Hard Disks\SSRSDDCM101_TEMP.vhdx'
ControllerType: SCSI
ControllerNumber: 0
ControllerLocation: 1
Ensure: Present
dependsOn:
- HyperVDsc/VMHyperV::SSRSDDCM101
- HyperVDsc/VHD::SSRSDDCM101_Disk_TEMP
- name: SSRSDDCM101_SecureBoot
type: PSDesiredStateConfiguration/Script
properties:
GetScript: |
@{ Result = 'SecureBoot' }
TestScript: |
$vm = Get-VM -Name 'SSRSDDCM101' -ErrorAction SilentlyContinue
if (-not $vm) { return $false }
$f = Get-VMFirmware -VMName 'SSRSDDCM101'
if ([bool]$f.SecureBootEnabled -ne $false) { return $false }
if ('MicrosoftWindows' -and ($f.SecureBootTemplate -ne 'MicrosoftWindows')) { return $false }
return $true
SetScript: |
Set-VMFirmware -VMName 'SSRSDDCM101' -EnableSecureBoot Off
dependsOn:
- HyperVDsc/VMHyperV::SSRSDDCM101
- name: SSRSDDCM101_CheckpointType
type: PSDesiredStateConfiguration/Script
properties:
GetScript: |
@{ Result = 'CheckpointType' }
TestScript: |
$vm = Get-VM -Name 'SSRSDDCM101' -ErrorAction SilentlyContinue
if (-not $vm) { return $false }
$v = Get-VM -Name 'SSRSDDCM101'
return ($v.CheckpointType.ToString() -eq 'Production')
SetScript: |
Set-VM -Name 'SSRSDDCM101' -CheckpointType Production
dependsOn:
- HyperVDsc/VMHyperV::SSRSDDCM101
- name: SSRSDDCM101_IntegrationServices
type: PSDesiredStateConfiguration/Script
properties:
GetScript: |
@{ Result = 'IntegrationServices' }
TestScript: |
$vm = Get-VM -Name 'SSRSDDCM101' -ErrorAction SilentlyContinue
if (-not $vm) { return $false }
$services = Get-VMIntegrationService -VMName 'SSRSDDCM101'
$required = @('Time Synchronization', 'Heartbeat', 'Key-Value Pair Exchange', 'Shutdown', 'VSS')
foreach ($svc in $services | Where-Object {$_.Name -in $required}) {
if (-not $svc.Enabled) { return $false }
}
return $true
SetScript: |
Enable-VMIntegrationService -VMName 'SSRSDDCM101' -Name 'Time Synchronization', 'Heartbeat', 'Key-Value Pair Exchange', 'Shutdown', 'VSS'
dependsOn:
- HyperVDsc/VMHyperV::SSRSDDCM101
- name: SSRSDDCM101_AutoStart
type: PSDesiredStateConfiguration/Script
properties:
GetScript: |
@{ Result = 'AutoStart' }
TestScript: |
$vm = Get-VM -Name 'SSRSDDCM101' -ErrorAction SilentlyContinue
if (-not $vm) { return $false }
$v = Get-VM -Name 'SSRSDDCM101'
return ($v.AutomaticStartAction -eq 'Start' -and $v.AutomaticStartDelay -eq 90)
SetScript: |
Set-VM -Name 'SSRSDDCM101' -AutomaticStartAction Start -AutomaticStartDelay 90
Set-VM -Name 'SSRSDDCM101' -AutomaticStopAction ShutDown
dependsOn:
- HyperVDsc/VMHyperV::SSRSDDCM101Suggested solution
If dependsOn is configured then I'd expect that this wouldn't fail as we know the VM does not yet exist and must be created first.
Operating system the target node is running
OsName : Microsoft Windows Server 2022 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture : 64-bit
WindowsVersion : 2009
WindowsBuildLabEx : 20348.1.amd64fre.fe_release.210507-1500
OsLanguage : en-US
OsMuiLanguages : {en-US, de-DE, es-ES, fr-FR…}
PowerShell version and build the target node is running
Name Value
---- -----
PSVersion 7.5.3
PSEdition Core
GitCommitId 7.5.3
OS Microsoft Windows 10.0.20348
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
HyperVDsc version
HyperVDsc 4.0.0 C:\Program Files\WindowsPowerShell\Modules\HyperVDsc\4.0.0\HyperVDsc.psd1
Metadata
Metadata
Assignees
Labels
No labels