forked from dsccommunity/HyperVDsc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSample_xVMScsiController_AddControllers.ps1
More file actions
68 lines (57 loc) · 1.7 KB
/
Sample_xVMScsiController_AddControllers.ps1
File metadata and controls
68 lines (57 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
configuration Sample_xVMScsiController
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost',
[Parameter(Mandatory = $true)]
[System.String]
$VMName,
[Parameter(Mandatory = $true)]
[System.String]
$VhdPath
)
Import-DscResource -ModuleName 'xHyper-V'
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
Node $NodeName
{
$diskNameOS = "$VMName-OS.vhdx"
# Install HyperV feature, if not installed - Server SKU only
WindowsFeature HyperV
{
Ensure = 'Present'
Name = 'Hyper-V'
}
# Create the VHD for the OS
xVHD DiskOS
{
Ensure = 'Present'
Name = $diskNameOS
Path = $VhdPath
Generation = 'vhdx'
MaximumSizeBytes = 20GB
DependsOn = '[WindowsFeature]HyperV'
}
# Create the VM
xVMHyperV NewVM
{
Ensure = 'Present'
Name = $VMName
VhdPath = Join-Path -Path $VhdPath -ChildPath $diskNameOS
Generation = 2
DependsOn = '[xVHD]DiskOS'
}
# Add and additional SCSI controller
xVMScsiController Controller
{
Ensure = 'Present'
VMName = $VMName
ControllerNumber = 1
DependsOn = '[xVMHyperV]NewVM'
}
}
}
$mofPath = "C:\temp\Sample_xVMScsiController"
Sample_xVMScsiController -VMName "test1" -VhdPath "C:\temp\Tests" -OutputPath $mofPath
Start-DscConfiguration -Path $mofPath -Verbose -Wait -Force