Using NetQoSDSC #PSDSC Resource Module to Configure Network QoS

As a part of larger hyper-converged infrastructure (based on S2D) configuration automation using PowerShell DSC, I have written quite a few new DSC resource modules. FailoverClusterDSC was one of the modules in that list. I added NetQoSDSC as well to ensure I have the automated means to configure the QoS policies in Windows Server 2016.

This module contains five resources at the moment.

Enable/Disable Network Adapter QoS

The NetAdapterQoS resource can be used to enable/disable QoS a specific network adapter.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Configuration NetAdapterQoS
{
    Import-DscResource -ModuleName PSDesiredStateConfiguration -ModuleVersion 1.1
    Import-DscResource -ModuleName NetQoSDSC -ModuleVersion 1.0.0.0

    NetAdapterQoS EnableAdapterQoS
    {
        NetAdapterName = 'Storage1'
        Ensure = 'Present'
     }
}

Enable/Disable DCBX Willing mode

DCBX willing mode can be enabled or disabled using the NetQoSDCBXSetting resource. This can be done at an interface level or at the global level in the operating system.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
Configuration DisableGlobalDCBX
{
    Import-DscResource -ModuleName PSDesiredStateConfiguration -ModuleVersion 1.1
    Import-DscResource -ModuleName NetQosDsc -ModuleVersion 1.0.0.0

    NetQoSDcbxSetting DisableGlobal
    {
        InterfaceAlias = 'Global'
        Willing = $false
     }

     NetQoSDcbxSetting EnableStorage1
     {
        InterfaceAlias = 'Storage1'
        Willing = $true
      }
}

Enable/Disable Network QoS flow control priorities

The NetQosFlowControl resource can be used to enable or disable 802.1P flow control priorities.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
Configuration NetQoSFlowControl
{
    Import-DscResource -ModuleName PSDesiredStateConfiguration -ModuleVersion 1.1
    Import-DscResource -ModuleName NetQoSDSC -ModuleVersion 1.0.0.0

    NetQoSFlowControl EnableP3
    {
       Id = 'Priority3'
       Priority = 3
       Enabled = $true
    }

    NetQoSFlowControl DisableRest
    {
        Id = 'RestPriority'
        Priority = @(0,1,2,4,5,6,7)
        Enabled = $false
     }
}

Create new QoS policies

New network QoS policies can be created using the NetQoSPolicy resource.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
Configuration NewNetQoSPolicy
{
    Import-DscResource -ModuleName PSDesiredStateConfiguration -ModuleVersion 1.1
    Import-DscResource -ModuleName NetQoSDSC -ModuleVersion 1.0.0.0

    NetQosPolicy SMB
    {
        Name = 'SMB'
        PriorityValue8021Action = 3
        PolicyStore = 'localhost'
        NetDirectPortMatchCondition = 445
        Ensure = 'Present'
     }
}

Manage Network QoS Traffic classes

The NetQoSTrafficClass resource can be used to manage the traffic classes in network QoS.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
Configuration NewTrafficClass
{
    Import-DscResource -ModuleName PSDesiredStateConfiguration -ModuleVersion 1.1
    Import-DscResource -ModuleName NetQoSDSC -ModuleVersion 1.0.0.0

    NetQosTrafficClass SMB
    {
        Name = 'SMB'
        Algorithm = 'ETS'
        Priority = 3
        BandwidthPercentage = 50
        Ensure = 'Present'
     }
}

This module, while code complete, needs some more work to declare as fully HQRM-compliant. I am working towards that by adding tests and better examples. Feel free to submit your issues, feedback, or PRs.

Share on: