-
Notifications
You must be signed in to change notification settings - Fork 65
VMScsiController
dscbot edited this page Jun 12, 2022
·
3 revisions
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
VMName | Key | String | Specifies the name of the virtual machine whose SCSI controller is to be manipulated. | |
ControllerNumber | Key | UInt32 | Specifies the number of the SCSI controller to be set. If not specified, it defaults to 0. |
0 , 1 , 2 , 3
|
Ensure | Write | String | Specifies if the SCSI controller should exist or not. If not specified, it defaults to Present . |
Present , Absent
|
RestartIfNeeded | Write | Boolean | If set to $true then shutdowns and restarts are allowed for the VM when needed for property changes. If not specified, it defaults to $false . |
Manages the SCSI controllers attached to a Hyper-V virtual machine.
When removing a controller, all the disks still connected to the controller will be detached.
- The Hyper-V Role has to be installed on the machine.
- The Hyper-V PowerShell module has to be installed on the machine.
Add a SCSI controller to a VM.
configuration Example
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost',
[Parameter(Mandatory = $true)]
[System.String]
$VMName,
[Parameter(Mandatory = $true)]
[System.String]
$VhdPath
)
Import-DscResource -ModuleName 'HyperVDsc'
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
VHD DiskOS
{
Ensure = 'Present'
Name = $diskNameOS
Path = $VhdPath
Generation = 'vhdx'
MaximumSizeBytes = 20GB
DependsOn = '[WindowsFeature]HyperV'
}
# Create the VM
VMHyperV NewVM
{
Ensure = 'Present'
Name = $VMName
VhdPath = Join-Path -Path $VhdPath -ChildPath $diskNameOS
Generation = 2
DependsOn = '[VHD]DiskOS'
}
# Add and additional SCSI controller
VMScsiController Controller
{
Ensure = 'Present'
VMName = $VMName
ControllerNumber = 1
DependsOn = '[VMHyperV]NewVM'
}
}
}