Skip to content

Commit ebcd72d

Browse files
authored
Migrate to HyperVDsc (#200)
1 parent 21a8df4 commit ebcd72d

4 files changed

Lines changed: 38 additions & 37 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ set to true when the LCM is already in ApplyAndAutoCorrect mode.
100100
- SqlServerDsc
101101
- xHyper-V
102102
- VSTSAgent
103+
- xHyper-V ==> HyperVDsc
103104
- Refactoring of SqlPermissions after upgrade of SqlServerDsc to 16.0.0
104105
- WindowsFeatures: Include support for more elaborate lists of features, giving
105106
more control.

RequiredModules.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
OfficeOnlineServerDsc = '1.5.0'
5252
xBitlocker = '1.4.0.0'
5353
ActiveDirectoryCSDsc = '5.0.0'
54-
'xHyper-V' = '3.18.0'
54+
HyperVDsc = '4.0.0-preview0005'
5555
DSCR_PowerPlan = '1.3.0'
5656
FileSystemDsc = '1.1.1'
5757
PackageManagement = '1.4.8.1'

doc/HyperV.adoc

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414

1515
// reference links as variables for using more than once
16-
:ref_xHyper-V: https://github.com/dsccommunity/xHyper-V[xHyper-V]
16+
:ref_HyperVDsc: https://github.com/dsccommunity/HyperVDsc[HyperVDsc]
1717

1818

1919
[cols="1,3a" options="autowidth" caption=]
2020
|===
2121
| Source | https://github.com/dsccommunity/CommonTasks/tree/main/source/DSCResources/HyperV
22-
| DSC Resource | https://github.com/dsccommunity/xHyper-V
23-
| Documentation | {ref_xHyper-V}
22+
| DSC Resource | https://github.com/dsccommunity/HyperVDsc
23+
| Documentation | {ref_HyperVDsc}
2424
|===
2525

2626

@@ -150,19 +150,19 @@ Only one NAT switch is supported on a Hyper-V host.
150150
|
151151

152152
| AddressSpace
153-
|
153+
|
154154
| String
155155
| Address space of virtual network defined in the format '192.168.10.0/24'
156156

157157
Mandatory attribute for a NAT switch!
158158
|
159159

160160
| IpAddress
161-
|
161+
|
162162
| String
163-
| The desired IP address of the network adapter which is connected to the Hyper-V switch.
163+
| The desired IP address of the network adapter which is connected to the Hyper-V switch.
164164

165-
Not applicable for `Private` switches!
165+
Not applicable for `Private` switches!
166166

167167
Mandatory attribute for a NAT switch and is used as default gateway for the virtual network.
168168
|
@@ -196,7 +196,7 @@ The server automatically sets the value of `DomainAuthenticated` when the networ
196196

197197
The acceptable values for this parameter are:
198198

199-
- Public - Networks in a public place such as an airport or coffee shop.
199+
- Public - Networks in a public place such as an airport or coffee shop.
200200
Your PC is hidden from other devices on the network and can't be used for printer and file sharing.
201201
- Private - Networks at home or work, where you know and trust the people and devices on the network.
202202
Your PC is discoverable and can be used for printer and file sharing if you set it up.
@@ -326,7 +326,7 @@ The acceptable values for this parameter are:
326326
- Standard -> Create standard checkpoints.
327327
- Production -> Create production checkpoints if supported by guest operating system.
328328
Otherwise, create standard checkpoints.
329-
- ProductionOnly -> Create production checkpoints if supported by guest operating system.
329+
- ProductionOnly -> Create production checkpoints if supported by guest operating system.
330330
Otherwise, the operation fails.
331331
| - Disabled
332332
- Standard
@@ -483,13 +483,13 @@ Allowed values are On, which drops DHCP messages because the virtualized DHCP se
483483
| - On
484484
- Off
485485

486-
| RouterGuard
486+
| RouterGuard
487487
|
488488
| String
489489
| Specifies whether to drop Router Advertisement and Redirection messages from unauthorized virtual machines.
490490

491-
The value can be either On or Off.
492-
If On is specified, such messages are dropped.
491+
The value can be either On or Off.
492+
If On is specified, such messages are dropped.
493493
If Off is specified, such messages are sent.
494494
| - On
495495
- Off
@@ -572,7 +572,7 @@ If Off is specified, such messages are sent.
572572
|
573573

574574
| [[dscyml_hyperv_vmmachines_disks_copyonce, {YmlCategory}/VMMachines/Disks/CopyOnce]]<<dscyml_hyperv_vmmachines_disks_copyonce_details, CopyOnce>>
575-
|
575+
|
576576
| Hashtable[]
577577
| Copy files from host to VM system disk *before first start* of VM
578578
|
@@ -612,9 +612,9 @@ Attribute shall be specified without drive letter (e.g: `Users\Default\Documents
612612
| Specifies a items that are excluded from the copy operation.
613613

614614
The value of this attributes qualifies the `Source` attribute.
615-
Enter a path element or pattern, such as `*.txt`.
615+
Enter a path element or pattern, such as `*.txt`.
616616
Wildcard characters are permitted.
617-
617+
618618
The attribute is effective only when the command includes the contents of an item, such as `C:\Windows\*``, where the wildcard character specifies the contents of the `C:\Windows` directory.
619619
|
620620

source/DSCResources/HyperV/HyperV.schema.psm1

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# see https://github.com/dsccommunity/xHyper-V
1+
# see https://github.com/dsccommunity/HyperVDsc
22
configuration HyperV
33
{
44
param
@@ -29,7 +29,7 @@ configuration HyperV
2929
)
3030

3131
Import-DscResource -ModuleName PSDesiredStateConfiguration
32-
Import-DscResource -ModuleName 'xHyper-V'
32+
Import-DscResource -ModuleName HyperVDsc
3333

3434
[string]$dependsOnHostOS = $null
3535

@@ -80,7 +80,7 @@ configuration HyperV
8080
$configHyperV.VirtualMachinePath = $VirtualMachinePath
8181
}
8282

83-
(Get-DscSplattedResource -ResourceName xVMHost -ExecutionName 'config_HyperVHost' -Properties $configHyperV -NoInvoke).Invoke($configHyperV)
83+
(Get-DscSplattedResource -ResourceName VMHost -ExecutionName 'config_HyperVHost' -Properties $configHyperV -NoInvoke).Invoke($configHyperV)
8484
#endregion
8585

8686
#######################################################################
@@ -143,7 +143,7 @@ configuration HyperV
143143

144144
$vmswitch.DependsOn = $dependsOnHostOS
145145
$executionName = $vmswitch.Name -replace '[().:\s]', '_'
146-
(Get-DscSplattedResource -ResourceName xVMSwitch -ExecutionName "vmswitch_$executionName" -Properties $vmswitch -NoInvoke).Invoke($vmswitch)
146+
(Get-DscSplattedResource -ResourceName VMSwitch -ExecutionName "vmswitch_$executionName" -Properties $vmswitch -NoInvoke).Invoke($vmswitch)
147147

148148
if ($vmswitch.Ensure -ne 'Absent')
149149
{
@@ -316,7 +316,7 @@ configuration HyperV
316316
result = 'N/A'
317317
}
318318
}
319-
DependsOn = "[xVMSwitch]vmswitch_$executionName"
319+
DependsOn = "[VMSwitch]vmswitch_$executionName"
320320
}
321321
}
322322

@@ -389,13 +389,13 @@ configuration HyperV
389389
$vmState = $vmmachine.State
390390
$vmmachine.Remove('State')
391391

392-
$strVMDepend = "[xVMHyperV]$vmName"
392+
$strVMDepend = "[VMHyperV]$vmName"
393393
$strVHDPath = "$($vmmachine.Path)\$vmName\Disks"
394394
$iMemorySize = ($vmmachine.StartupMemory / 1MB) * 1MB
395395

396396
if ($vmmachine.Ensure -eq 'Absent')
397397
{
398-
xVMHyperV $vmName
398+
VMHyperV $vmName
399399
{
400400
Ensure = 'Absent'
401401
Name = $vmName
@@ -454,8 +454,8 @@ configuration HyperV
454454
else
455455
{
456456
$iDiskSize = ($disk.Size / 1GB) * 1GB
457-
$strVHDDepend = "[xVHD]$strVHD"
458-
xVHD $strVHD
457+
$strVHDDepend = "[VHD]$strVHD"
458+
VHD $strVHD
459459
{
460460
Name = $strVHDName
461461
Path = $strVHDPath
@@ -684,9 +684,9 @@ configuration HyperV
684684
$vmmachine.MacAddress = $macAddrList
685685
}
686686

687-
(Get-DscSplattedResource -ResourceName xVMHyperV -ExecutionName $vmName -Properties $vmmachine -NoInvoke).Invoke($vmmachine)
687+
(Get-DscSplattedResource -ResourceName VMHyperV -ExecutionName $vmName -Properties $vmmachine -NoInvoke).Invoke($vmmachine)
688688

689-
$strVMdepends = "[xVMHyperV]$vmName"
689+
$strVMdepends = "[VMHyperV]$vmName"
690690

691691
# additional VM settings
692692
if ($null -ne $checkpointType -or
@@ -952,7 +952,7 @@ configuration HyperV
952952

953953
if ($netAdapter.NetworkSetting -ne $null)
954954
{
955-
$netSetting = xNetworkSettings
955+
$netSetting = VMNetworkAdapterNetworkSettings
956956
{
957957
IpAddress = $netAdapter.NetworkSetting.IpAddress
958958
Subnet = $netAdapter.NetworkSetting.Subnet
@@ -979,7 +979,7 @@ configuration HyperV
979979

980980
$execName = "netadapter_$($netAdapter.Id)"
981981

982-
(Get-DscSplattedResource -ResourceName xVMNetworkAdapter -ExecutionName $execName -Properties $netAdapter -NoInvoke).Invoke($netAdapter)
982+
(Get-DscSplattedResource -ResourceName VMNetworkAdapter -ExecutionName $execName -Properties $netAdapter -NoInvoke).Invoke($netAdapter)
983983

984984
Script "$($execName)_properties"
985985
{
@@ -1044,7 +1044,7 @@ configuration HyperV
10441044
result = 'N/A'
10451045
}
10461046
}
1047-
DependsOn = "[xVMNetworkAdapter]$execName"
1047+
DependsOn = "[VMNetworkAdapter]$execName"
10481048
}
10491049
}
10501050

@@ -1092,8 +1092,8 @@ configuration HyperV
10921092
else
10931093
{
10941094
$iDiskSize = ($disk.Size / 1GB) * 1GB
1095-
$strVHDDepend = "[xVHD]$strVHD"
1096-
xVHD $strVHD
1095+
$strVHDDepend = "[VHD]$strVHD"
1096+
VHD $strVHD
10971097
{
10981098
Name = $strVHDName
10991099
Path = $disk.Path
@@ -1106,7 +1106,7 @@ configuration HyperV
11061106

11071107
# attach the VHD file to the virtual machine
11081108
$executionName = "$($vmName)_DiskAttach_$($disk.Name)"
1109-
xVMHardDiskDrive $executionName
1109+
VMHardDiskDrive $executionName
11101110
{
11111111
Ensure = 'Present'
11121112
VMName = $vmName
@@ -1118,7 +1118,7 @@ configuration HyperV
11181118
}
11191119

11201120
++$iLocation
1121-
$strHddDepends = "[xVMHardDiskDrive]$executionName"
1121+
$strHddDepends = "[VMHardDiskDrive]$executionName"
11221122
}
11231123

11241124
# create virtual drives and mount ISO files
@@ -1130,7 +1130,7 @@ configuration HyperV
11301130

11311131
if ($drive.Path.Length)
11321132
{
1133-
xVMDvdDrive $executionName
1133+
VMDvdDrive $executionName
11341134
{
11351135
Ensure = 'Present'
11361136
VMName = $vmName
@@ -1142,7 +1142,7 @@ configuration HyperV
11421142
}
11431143
else
11441144
{
1145-
xVMDvdDrive $executionName
1145+
VMDvdDrive $executionName
11461146
{
11471147
Ensure = 'Present'
11481148
VMName = $vmName
@@ -1153,7 +1153,7 @@ configuration HyperV
11531153
}
11541154

11551155
++$iLocation
1156-
$strDvdDepends = "[xVMDvdDrive]$executionName"
1156+
$strDvdDepends = "[VMDvdDrive]$executionName"
11571157
}
11581158

11591159
# change boot order: first hdd -> system drive, last dvd -> OS install

0 commit comments

Comments
 (0)