I'd like to programmatically create a new Network Profile (in addtion to those listed under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles
). Then I'd like to programmatically assign a particular network adapter to it (e.g., vEthernet (WSL)
), and set the profile to Private
network mode to follow the firewall rules, similar to what we can do for Wi-Fi networks. Is there a Windows or PowerShell API to help with that?
Eventually, the goal is to access Windows network from WSL2 Linux without tweaking the Windows Firewall settings manually.
More context for the question, including some things I've tried so far.
Currently, my solution is to call New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)"
manually each time I need access the Windows host network from WSL2.