Author Posts

October 2, 2015 at 3:22 am

Hi,

I am trying to set up a DSC resource to deploy a Hyper-V Converged virtual network using this as a guide (http://www.powershellmagazine.com/2015/01/20/using-dsc-to-deploy-hyper-v-converged-virtual-network-creating-a-host-team-part-1/). However this does set the networking/DNS properties of the NIC Team – this is not something I want to do manually as it would defeat the object of DSC (and I need to set a specific IP address). My research has lead me to here (https://www.penflip.com/powershellorg/the-dsc-book/blob/master/writing-a-custom-dsc-resource.txt) – Writing Composite DSC Resources.

Individually, both work as they should – create the NIC team, then set the IPv4 & DNS settings. However, if I try to combine them I get the following error:

PSDesiredStateConfiguration\Node : The module 'CommonConfig' could not be loaded. For more information, run 'Import-Module CommonConfig'.
At line:6 char:5
+     Node Localhost {
+     ~~~~
    + CategoryInfo          : ObjectNotFound: (CommonConfig\CommonConfig:String) [PSDesiredStateConfiguration\node], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : CouldNotAutoLoadModule,PSDesiredStateConfiguration\node
 
Errors occurred while processing configuration 'HyperVConvergedNet'.
At C:\windows\system32\windowspowershell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:2223 char:5
+     throw $errorRecord
+     ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (HyperVConvergedNet:String) [], InvalidOperationException
    + FullyQualifiedErrorId : FailToProcessConfiguration
Configuration HyperVConvergedNet {
    Import-DscResource -Module cWindowsOS -Name cNetworkTeam
    Import-DscResource -ModuleName CommonConfigModule
    
    # Create Network Team named HostTeam adding all NICs as members
    Node Localhost {
        cNetworkTeam NetworkTeam {
            Name = 'HostTeam'
            TeamingMode = 'SwitchIndependent'
            LoadBalancingAlgorithm = 'HyperVPort'
            TeamMembers = 'NIC1','NIC2','NIC3','NIC4'
            Ensure = 'Present'
        }
        # Assign an IP address to HostTeam 
        CommonConfig Common {
           IPAddress = "192.168.192.202"
           DependsOn = '[cNetworkTeam]NetworkTeam'
        }
    }
}

Any help appreciated, thanks
Tony

October 3, 2015 at 11:48 am

I assume the DSC resource modules are stored under

C:\Program Files\WindowsPowerShell\Modules\

?