VMSwitch: VM switch repeatedly created when BandwidthReservationMode set to 'NA' or 'Default' on an internal switch
Details of the scenario you tried and the problem that is occurring:
If BandwidthReservationMode is set to 'NA' or 'Default' in an xVMSwitch resource with Type 'Internal', the switch gets created repeatedly on each pass of DSC. After looking at the source, it seems that 'NA' is a value reserved for older OS versions that do not support this feature. If so, then there should be a check for this invalid condition instead of the current behavior. In the case of 'Default', Hyper-V will set the actual parameter value to something besides 'Default' using some logic, causing Test-TargetResource to fail when it checks BandwidthReservationMode again. Then, in Set-TargetResource, for some reason the code assumes that if the switch type is not 'External', Test-TargetResource failing means a new switch needs to be created.
The DSC configuration that is using the resource (as detailed as possible):
The following script will create each switch 3 times:
Configuration BandwidthReservationModeBug {
Import-DscResource -ModuleName xHyper-V
Node localhost {
xVMSwitch NA {
Name = 'BandwidthReservationModeBug NA'
Type = 'Internal'
BandwidthReservationMode = 'NA'
}
xVMSwitch Default {
Name = 'BandwidthReservationModeBug Default'
Type = 'Internal'
BandwidthReservationMode = 'Default'
}
}
}
BandwidthReservationModeBug -OutputPath 'BandwidthReservationModeBug'
Start-DscConfiguration -Wait -Verbose -Force -Path 'BandwidthReservationModeBug'
Start-DscConfiguration -Wait -Verbose -Force -Path 'BandwidthReservationModeBug'
Start-DscConfiguration -Wait -Verbose -Force -Path 'BandwidthReservationModeBug'
Version of the Operating System and PowerShell the DSC Target Node is running:
Windows 10.0.15063
PSVersion 5.1.15063.726 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.15063.726 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
Version of the DSC module you're using, or 'dev' if you're using current dev branch:
3.9.0.0