Examples/MultipleNetworkExample.ps1

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
<#
    .SYNOPSIS
        Example configuration for consistently deploying VMs with
        multiple network adapters using MAC address for mapping.
#>

configuration MultipleNetworkExample {
    param ()

    Import-DscResource -ModuleName xNetworking;

    node $AllNodes.NodeName {

        ## Enumerate all MAC addresses of the node
        for ($i = 0; $i -lt @($node.Lability_MACAddress).Count; $i++) {

            ## Use the NetAdapterName resource to rename the network adapter
            ## to the corresponding 'NICName' using the MAC address key.
            xNetAdapterName "RenameNetAdapter$i" {

                NewName    = $node.Lability_NICName[$i];
                MacAddress = $node.Lability_MACAddress[$i];
            }

        } #end for

    } #end node

} #end configuration