-
Notifications
You must be signed in to change notification settings - Fork 65
VMSwitch
dscbot edited this page Jun 12, 2022
·
3 revisions
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
Name | Key | String | The desired VM Switch name. | |
Type | Key | String | The desired type of switch. |
External , Internal , Private
|
NetAdapterName | Write | StringArray[] | Network adapter name(s) for external switch type. | |
AllowManagementOS | Write | Boolean | Specify if the VM host has access to the physical NIC. The default value is $false . |
|
EnableEmbeddedTeaming | Write | Boolean | Should embedded NIC teaming be used (Windows Server 2016 or higher only). The default value is $false . |
|
BandwidthReservationMode | Write | String | Specify the QoS mode used (options other than NA are only supported on Hyper-V 2012 or higher). The default value is NA . |
Default , Weight , Absolute , None , NA
|
LoadBalancingAlgorithm | Write | String | Specify the Load Balancing algorithm which should be used for the embedded NIC teaming. |
Dynamic , HyperVPort
|
Ensure | Write | String | Ensures that the VM Switch is Present or Absent. The default value is Present . |
Present , Absent
|
Id | Write | String | Specify the desired Unique ID of the Hyper-V switch. If not specified the ID will be generated by the system every time the Hyper-V Switch is created. (Windows Server 2016 or higher only) | |
NetAdapterInterfaceDescription | Read | String | Returns the description of the network interface. |
Manages virtual switches in a Hyper-V host.
- The Hyper-V Role has to be installed on the machine.
- The Hyper-V PowerShell module has to be installed on the machine.
Creates a switch of the type External.
configuration Example
{
param
(
[System.String[]]
$NodeName = 'localhost',
[Parameter(Mandatory = $true)]
[System.String]
$SwitchName,
[Parameter(Mandatory = $true)]
[System.String]
$NetAdapterName
)
Import-DscResource -ModuleName 'HyperVDsc'
Node $NodeName
{
# Install HyperV feature, if not installed - Server SKU only
WindowsFeature HyperV
{
Ensure = 'Present'
Name = 'Hyper-V'
}
# Ensures a VM with default settings
VMSwitch ExternalSwitch
{
Ensure = 'Present'
Name = $SwitchName
Type = 'External'
NetAdapterName = $NetAdapterName
DependsOn = '[WindowsFeature]HyperV'
}
}
}
Creates a switch that is of type External and using load balancing.
Configuration Example
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost',
[Parameter(Mandatory = $true)]
[System.String]
$SwitchName,
[Parameter(Mandatory = $true)]
[System.String[]]
$NetAdapterNames
)
Import-DscResource -ModuleName 'HyperVDsc'
Node $NodeName
{
# Install HyperV feature, if not installed - Server SKU only
WindowsFeature HyperV
{
Ensure = 'Present'
Name = 'Hyper-V'
}
WindowsFeature HyperVTools
{
Ensure = 'Present'
Name = 'RSAT-Hyper-V-Tools'
DependsOn = '[WindowsFeature]HyperV'
}
# Ensures a VM with Load Balancing Algorithm 'Hyper-V Port"
VMSwitch ExternalSwitch
{
Ensure = 'Present'
Name = $SwitchName
Type = 'External'
NetAdapterName = $NetAdapterNames
EnableEmbeddedTeaming = $true
LoadBalancingAlgorithm = 'HyperVPort'
DependsOn = '[WindowsFeature]HyperVTools'
}
}
}
Creates a switch of the type External and uses embedded teaming.
Configuration Example
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost',
[Parameter(Mandatory = $true)]
[System.String]
$SwitchName,
[Parameter(Mandatory = $true)]
[System.String[]]
$NetAdapterNames
)
Import-DscResource -ModuleName 'HyperVDsc'
Node $NodeName
{
# Install HyperV feature, if not installed - Server SKU only
WindowsFeature HyperV
{
Ensure = 'Present'
Name = 'Hyper-V'
}
WindowsFeature HyperVTools
{
Ensure = 'Present'
Name = 'RSAT-Hyper-V-Tools'
DependsOn = '[WindowsFeature]HyperV'
}
# Ensures a VM with default settings
VMSwitch ExternalSwitch
{
Ensure = 'Present'
Name = $SwitchName
Type = 'External'
NetAdapterName = $NetAdapterNames
EnableEmbeddedTeaming = $true
DependsOn = '[WindowsFeature]HyperVTools'
}
}
}
Creates a switch of the type Internal.
configuration Example
{
param
(
[System.String[]]
$NodeName = 'localhost',
[Parameter(Mandatory = $true)]
[System.String]
$SwitchName
)
Import-DscResource -ModuleName 'HyperVDsc'
Node $NodeName
{
# Install HyperV feature, if not installed - Server SKU only
WindowsFeature HyperV
{
Ensure = 'Present'
Name = 'Hyper-V'
}
# Ensures a VM with default settings
VMSwitch InternalSwitch
{
Ensure = 'Present'
Name = $SwitchName
Type = 'Internal'
DependsOn = '[WindowsFeature]HyperV'
}
}
}