-
Notifications
You must be signed in to change notification settings - Fork 64
VMNetworkAdapter
dscbot edited this page Jun 12, 2022
·
3 revisions
| Parameter | Attribute | DataType | Description | Allowed Values |
|---|---|---|---|---|
| Id | Key | String | Unique string for identifying the resource instance. | |
| Name | Required | String | Name of the network adapter as it appears either in the management OS or attached to a VM. | |
| SwitchName | Required | String | Virtual Switch name to connect to. | |
| VMName | Required | String | Name of the VM to attach to. If you want to attach new VM Network adapter to the management OS, set this property to 'ManagementOS'. | |
| MacAddress | Write | String | Use this to specify a Static MAC Address. If this parameter is not specified, dynamic MAC Address will be set. | |
| NetworkSetting | Write | NetworkSettings | Network Settings of the network adapter. If this parameter is not supplied, DHCP will be used. | |
| VlanId | Write | String | Use this to specify a Vlan id on the Network Adapter. | |
| Ensure | Write | String | Ensures that the VM Network Adapter is Present or Absent. The default value is Present. |
Present, Absent
|
| DynamicMacAddress | Read | Boolean | Returns $true if the network adapter uses a dynamic MAC address. |
| Parameter | Attribute | DataType | Description | Allowed Values |
|---|---|---|---|---|
| IpAddress | Write | String | IpAddress to give the network adapter. Only used if not Dhcp. Required if not Dhcp. | |
| Subnet | Write | String | Subnet to give the network adapter. Only used if not Dhcp. Required if not Dhcp. | |
| DefaultGateway | Write | String | DefaultGateway to give the network adapter. Only used if not Dhcp. | |
| DnsServer | Write | String | DNS server to give the network adapter. Only used if not Dhcp. |
Manages VM network adapters attached to a Hyper-V virtual machine or the management OS.
- The Hyper-V Role has to be installed on the machine.
- The Hyper-V PowerShell module has to be installed on the machine.
Description not yet written.
Configuration Example
{
Import-DscResource -ModuleName 'HyperVDsc' -Name VMNetworkAdapter
Import-DscResource -ModuleName PSDesiredStateConfiguration
VMNetworkAdapter HostOSAdapter {
Id = 'Management-NIC'
Name = 'Management-NIC'
SwitchName = 'SETSwitch'
VMName = 'ManagementOS'
Ensure = 'Present'
}
}Description not yet written.
Configuration Example
{
Import-DscResource -ModuleName 'HyperVDsc' -Name VMNetworkAdapter
Import-DscResource -ModuleName PSDesiredStateConfiguration
VMNetworkAdapter ManagementAdapter {
Id = 'Management-NIC'
Name = 'Management-NIC'
SwitchName = 'SETSwitch'
VMName = 'ManagementOS'
Ensure = 'Present'
}
VMNetworkAdapter ClusterAdapter {
Id = 'Cluster-NIC'
Name = 'Cluster-NIC'
SwitchName = 'SETSwitch'
VMName = 'ManagementOS'
Ensure = 'Present'
}
}Add three network adapters to the same switch.
Configuration Example
{
Import-DscResource -ModuleName 'HyperVDsc' -Name VMNetworkAdapter
Import-DscResource -ModuleName PSDesiredStateConfiguration
VMNetworkAdapter MyVM01NIC {
Id = 'MyVM01-NIC'
Name = 'MyVM01-NIC'
SwitchName = 'SETSwitch'
VMName = 'MyVM01'
Ensure = 'Present'
}
VMNetworkAdapter MyVM02NIC {
Id = 'MyVM02-NIC'
Name = 'NetAdapter'
SwitchName = 'SETSwitch'
VMName = 'MyVM02'
Ensure = 'Present'
}
VMNetworkAdapter MyVM03NIC {
Id = 'MyVM03-NIC'
Name = 'NetAdapter'
SwitchName = 'SETSwitch'
VMName = 'MyVM03'
Ensure = 'Present'
}
}Description not yet written.
Configuration Example
{
Import-DscResource -ModuleName 'HyperVDsc' -Name VMNetworkAdapter
Import-DscResource -ModuleName PSDesiredStateConfiguration
VMNetworkAdapter MyVM01NIC {
Id = 'MyVM01-NIC'
Name = 'MyVM01-NIC'
SwitchName = 'SETSwitch'
MacAddress = '001523be0c00'
VMName = 'MyVM01'
Ensure = 'Present'
}
VMNetworkAdapter MyVM02NIC {
Id = 'MyVM02-NIC'
Name = 'MyVM02-NIC'
SwitchName = 'SETSwitch'
MacAddress = '001523be0c00'
VMName = 'MyVM02'
Ensure = 'Present'
}
}Add a network adapter that is using static IP address.
Configuration Example
{
Import-DscResource -ModuleName 'HyperVDsc'
VMNetworkAdapter MyVM01NIC
{
Ensure = 'Present'
Id = 'MyVM01-NIC'
Name = 'MyVM01-NIC'
SwitchName = 'SETSwitch'
MacAddress = '001523be0c00'
VMName = 'MyVM01'
NetworkSetting = NetworkSettings
{
IpAddress = '192.168.0.100'
Subnet = '255.255.255.255'
DefaultGateway = '192.168.0.1'
DnsServer = '192.168.0.1'
}
}
}Add a network adapter that is using a VLAN tag.
Configuration Example
{
Import-DscResource -ModuleName 'HyperVDsc' -Name VMNetworkAdapter
Import-DscResource -ModuleName PSDesiredStateConfiguration
VMNetworkAdapter MyVM01NIC {
Id = 'MyVM01-NIC'
Name = 'MyVM01-NIC'
SwitchName = 'SETSwitch'
MacAddress = '001523be0c00'
VMName = 'MyVM01'
VlanId = '1'
Ensure = 'Present'
}
}