How to create network traces in Windows

Above Windows Server 2019 and Windows 10:

pktmon start --capture
{reproduce the issue}
pktmon stop
pktmon etl2pcap PktMon.etl --out PktMon.pcapng

Older Windows:

netsh trace start capture=yes tracefile=<location>
netsh trace stop

To convert the .etl file to .pcapng : https://github.com/microsoft/etl2pcapng