Reputation: 2582
I'm trying to create a Network Bridge with Powershell, but there is no documentation on where to start.
Is it posible to create a network bridge with powershell between two network adapters on a Windows 10 machine?
Upvotes: 8
Views: 14468
Reputation: 8456
It looks like Microsoft added a Netsh bridge create command in Windows 11
[...] available beginning with 2023-09 Cumulative Update for Windows 11, version 22H2 (KB5030310)
Upvotes: 0
Reputation: 11
It can be done. I've done it for 4 port NICs. It's not a pretty solution but it works. Think of the manual process you go through to create a NIC bridge. You can replicate the GUI manipulation using "sendkeys". (Like I said, it's not pretty.) One thing you should consider doing is locking the keyboard and mouse as you're creating the bridge. If the window focus is changed during the build, it will mess things up. Additionally, I had to include a verification search at the end of the initial build process to confirm that all required NICs were added to the bridge. If any weren't, I had to create another "Sendkey" routine to add the NICs individually. Since I've never found another way to programmatically create a NIC bridge we're still using this process.
Upvotes: 1
Reputation: 543
According to Microsoft (from June 2019 and still valid as of June 27, 2020):
There is no supported way to programmatically create a bridge. Bridges can only be created through the GUI.
Also, the link given in other answers actually shows that netsh
cannot be used (see the Remarks section):
The install and uninstall commands are not supported in the netsh bridge context. Network Bridge can be set up or removed only through Network Connections.
The only supported commands are:
netsh bridge show adapter
netsh bridge set adapter
Just like the quote says, on Windows 10 Pro, netsh bridge install
gives the message that @SalamiArmy posted:
Not supported. Please go to the Network Connections folder to install.
Network Connections is the page where you can change adapter settings: Control Panel\Network and Internet\Network Connections
.
Upvotes: 10
Reputation: 857
You can use the powershell commands for collecting adapter information such as Get-NetAdapter
or Get-NetIPConfiguration
found here. Once you have collected the information you need to set up the bridge, then you call netsh bridge set ...
with your configuration preferences. For more info on the netsh bridge command, look here
Upvotes: 2
Reputation: 413
This cannot be done.
Entering the command "netsh bridge install ?" into Powershell:
Not supported. Please go to the Network Connections folder to install.
EDIT: On Windows Server 2016 Core:
The following command was not found: bridge install ?
Upvotes: 0