SkillPilotAI

PowerShell NetQos module

NetQos is the built-in Windows module for QoS policies: a policy matches outgoing traffic (app, IP, port, template) and applies an action (DSCP mark, 802.1p priority, throttle, minimum bandwidth). It decides who goes first on a congested link.

232.1 Why is it used?

  • Voice/video calls stay smooth while a backup or big download runs.
  • Bulk traffic (backup, FTP) can be speed-limited so it does not eat the link.
  • Marks packets (DSCP / 802.1p) so switches and routers can queue them correctly.
  • Only 4 cmdlets: Get / New / Set / Remove-NetQosPolicy; New/Set/Remove need an admin shell.

232.2 How it works

Voice policy: match -> mark -> priority queue
  1. 1.Admin creates a Voice policy: match softphone.exe, DSCPAction 46

  2. 2.Voice packet leaves the PC marked DSCP 46 (EF) in the IP header

  3. 3.Switch trusts the DSCP marking

  4. 4.Router puts EF in the priority queue and forwards it first to the voice server

  5. 5.Backup packet matched no policy: DSCP 0, waits in the normal queue

The mark is only a label: the network must trust it and have an EF queue

  • ThrottleRateActionBitsPerSecond: speed limit, e.g. backup to ports 3501-3505 limited to 100MB (~105 Mbps).
  • PriorityValue8021Action: 802.1p priority 0-7 in the VLAN tag, read by the switch.
  • A Windows QoS policy applies to OUTBOUND traffic only.

232.3 Common DSCP values

DSCPNameTypical useToS byte
46EFVoice / VoIP0xb8
34AF41Video call0x88
26AF31Business app-
8CS1Scavenger / backup (low priority)-
0BEBest effort (default)0x0
  • DSCP is the upper 6 bits of the ToS byte, so 46 shows up as 0xb8 and 34 as 0x88 in tcpdump.

232.4 What was run on Windows (read-only)

PowerShell
Get-Command -Module NetQos | Measure-ObjectGet-Help New-NetQosPolicy
Output
$ Get-Command -Module NetQos | Measure-ObjectCount    : 4$ Get-Help New-NetQosPolicy   (synopsis, trimmed)New-NetQosPolicy [-Name] <string> [-PolicyStore <string>] [-NetworkProfile  <NetworkProfile>] [-Precedence <uint32>] [-PriorityValue8021Action <sbyte>]  [-DSCPAction <sbyte>] [-MinBandwidthWeightAction <byte>]  [-ThrottleRateActionBitsPerSecond <uint64>] [-IPDstPrefixMatchCondition <string>] ...New-NetQosPolicy [-Name] <string> -IPPortMatchCondition <uint16> ...New-NetQosPolicy [-Name] <string> -URIMatchCondition <string> ...New-NetQosPolicy [-Name] <string> -SMB ...New-NetQosPolicy [-Name] <string> -NFS ...New-NetQosPolicy [-Name] <string> -iSCSI ...New-NetQosPolicy [-Name] <string> -Default ...(11 parameter sets in total)
  • 4 cmdlets in the module.
  • 11 parameter sets: each built-in template (SMB, NFS, iSCSI, Default...) has its own set and cannot be mixed with other match conditions.

232.5 Common parameters

ParameterWhat it does
-AsJobRun as a background job
-CimSessionRun on a remote computer (e.g. Server01)
-ThrottleLimitMax concurrent operations
-ConfirmAsk before running (New/Set/Remove)
-WhatIfOnly show what would happen, do not run

232.6 Get-NetQosPolicy

PowerShell
Get-NetQoSPolicyGet-NetQosPolicy -PolicyStore "ActiveStore"Get-NetQosPolicy -Name "SMB policy" | Format-List -Property *
Output
PS C:\> Get-NetQosPolicy -PolicyStore "ActiveStore"   (trimmed)Name           : backupOwner          : Group Policy (Machine)NetworkProfile : DomainPrecedence     : 127IPProtocol     : BothDSCPValue      : 40 Name           : ftpOwner          : PowerShell / WMINetworkProfile : AllAppPathName    : ftp.exeThrottleRate   : 1 MBytes/sec
  • No -PolicyStore: the local computer store.
  • ActiveStore: every policy effective right now, from Group Policy or PowerShell (see the Owner field).

232.7 New-NetQosPolicy: match conditions

PowerShell
New-NetQosPolicy -Name "Backup" -IPDstPrefixMatchCondition "10.1.1.176/28" -NetworkProfile Domain -DSCPAction 40
Output
Name           : BackupOwner          : Group Policy (Machine)NetworkProfile : DomainPrecedence     : 127IPProtocol     : BothIPDstPrefix    : 10.1.1.176/28DSCPValue      : 40
Match conditionMatches
-AppPathNameMatchConditionAn application, e.g. ftp.exe
-IPDstPrefix / -IPSrcPrefixIP or subnet
-IPDstPort / -IPSrcPort, ...PortStart/EndExact port or port range
-IPProtocolMatchConditionNone | TCP | UDP | Both
-UserMatchConditionAD user or group
-URIMatchCondition (+ -URIRecursive)HTTP URL only
-NetworkProfileDomain | Public | Private | All

232.8 New-NetQosPolicy: templates and actions

PowerShell
New-NetQosPolicy -Name "FTP" -AppPathNameMatchCondition "ftp.exe" -ThrottleRateActionBitsPerSecond 1MB -PolicyStore ActiveStore
Output
Name           : FTPOwner          : PowerShell / WMINetworkProfile : AllPrecedence     : 127AppPathName    : ftp.exeThrottleRate   : 1.049 MBits/sec
  • Templates (used alone): -SMB 445, -NFS 2049, -iSCSI 3260, -LiveMigration 6600, -Cluster 3343, -FCOE (EtherType), -Default (all remaining traffic).
  • Actions: -DSCPAction 0-63, -PriorityValue8021Action 0-7, -MinBandwidthWeightAction 1-100, -ThrottleRateActionBitsPerSecond (bits/sec).
  • 1MB throttle = bits per second, hence ~1.049 MBits/sec in the output.
  • -Precedence 0-255 (default 127); higher wins in a conflict.

232.9 Set-NetQosPolicy and Remove-NetQosPolicy

PowerShell
Set-NetQosPolicy -Name "SMB Policy" -NetworkProfile DomainGet-NetQosPolicy -Name "wildcard" | Set-NetQosPolicy -Precedence 250Set-NetQosPolicy -Name "Backup" -IPDstPortStart 3501 -IPDstPortEnd 3510Set-NetQosPolicy -Name "IIS" -Recursive $True -ThrottleRateActionBitsPerSecond 3000KB
  • Set accepts every match + action option of New, plus -TemplateMatchCondition.
  • PolicyStore cannot be changed: to make an ActiveStore policy persistent, create a new policy.
PowerShell
Remove-NetQosPolicy -Name "Backup"Remove-NetQosPolicy -InputObject $objRemove-NetQosPolicy -Name "Backup" -WhatIf   # check first
  • Warning: Remove-NetQosPolicy with no -Name removes ALL policies in that store; run with -WhatIf first.

232.10 Linux equivalent lab (nftables DSCP marking)

Docker lab: n232-client 192.168.253.10 (NET_ADMIN) and n232-server 192.168.253.20; nf_tables is built into the kernel, so no module was loaded.

Lab flow
  1. 1.nft output rule on client: tcp dport 5201 -> ip dscp set ef

  2. 2.iperf3 to port 5201 (marked) and 5202 (unmarked)

  3. 3.tcpdump -v on server: 5201 tos 0xb8, 5202 tos 0x0

  4. 4.nft replace rule: ef -> af41, now 5201 shows tos 0x88

  5. 5.nft delete rule: both flows back to tos 0x0

Terminal
# client (NET_ADMIN): DSCPAction 46 ideanft add table ip n232nft add chain ip n232 out '{ type filter hook output priority 0; }'nft add rule ip n232 out tcp dport 5201 counter ip dscp set efiperf3 -c 192.168.253.20 -p 5201 -t 1 -b 1Miperf3 -c 192.168.253.20 -p 5202 -t 1 -b 1M# server: capture the SYNstcpdump -n -v -i eth0 -c 4 'tcp[tcpflags] == tcp-syn and src 192.168.253.10'
Output
[client] $ nft -a list table ip n232table ip n232 { # handle 2	chain out { # handle 1		type filter hook output priority filter; policy accept;		tcp dport 5201 counter packets 0 bytes 0 ip dscp set ef # handle 2	}}[server] $ cat /tmp/cap.txt   (tcpdump -v, trimmed)IP (tos 0xb8, ttl 64, ... proto TCP (6), length 60)    192.168.253.10.46696 > 192.168.253.20.5201: Flags [S], ...IP (tos 0x0, ttl 64, ... proto TCP (6), length 60)    192.168.253.10.34026 > 192.168.253.20.5202: Flags [S], ...4 packets captured
Terminal
nft replace rule ip n232 out handle 2 tcp dport 5201 counter ip dscp set af41   # Set-NetQosPolicy idea
Output
[server] $ cat /tmp/cap.txt   (tcpdump -v, trimmed)IP (tos 0x88, ttl 64, ... proto TCP (6), length 60)    192.168.253.10.52972 > 192.168.253.20.5201: Flags [S], ...IP (tos 0x0, ttl 64, ... proto TCP (6), length 60)    192.168.253.10.56436 > 192.168.253.20.5202: Flags [S], ...4 packets captured
Terminal
nft delete rule ip n232 out handle 2   # Remove-NetQosPolicy idea
Output
[server] $ cat /tmp/cap.txt   (tcpdump -v, trimmed)IP (tos 0x0, ttl 64, ... proto TCP (6), length 60)    192.168.253.10.42136 > 192.168.253.20.5201: Flags [S], ...    192.168.253.10.56976 > 192.168.253.20.5202: Flags [S], ...4 packets captured
  • Throttle (-ThrottleRateActionBitsPerSecond) is shown from the docs only: on Linux it needs tc qdiscs (tbf/htb), which are kernel modules here and were not loaded.

232.11 Common mistakes

  • Thinking QoS adds bandwidth: it only prioritises and limits during congestion.
  • Expecting a PC policy to control download speed: Windows QoS is outbound only.
  • Marking EF on the PC but the switch/router does not trust DSCP or has no EF priority queue: calls still break up.
  • Remove-NetQosPolicy without -Name: empties the whole store.

232.12 Interview tips

  • A policy = match conditions (app path, IP prefix, port, protocol, template) + actions (DSCP, 802.1p, throttle, min bandwidth).
  • Stores: localhost, ActiveStore, or pushed by Group Policy in a domain.
  • Precedence 0-255, higher wins; outbound traffic only.
  • EF = 46 (voice), AF41 = 34 (video), 0 = best effort; DSCP is the top 6 bits of ToS.
  • Marking only works end to end if the network trusts it.