When you deploy a Hyper-V cluster, it is painful to configure the network. Different vendors or changed hardware la s are only two examples of challenges for automated deployment. In this article, I will share with you how PowerShell collects information about which network adapter is located on what PCI bus. You can use this information to rename the network adapter, combine and change the network adapter settings.
We start by collecting information about existing network adapters. The PowerShell command to complete this process is as follows:
Get-WMIObject Win32_PNPSignedDriver | where {$ _. DeviceClass-eq "NET"-and $ _. HardWareID-like "* PCI *"}
The result is shown in:
In the output, we find the network adapter location. You may think that if the server has 12 network adapters, it is not practical. Then we can add | ft Location in this PowerShell command to collect PCI bus information.
Get-WMIObject Win32_PNPSignedDriver | where {$ _. DeviceClass-eq "NET"-and $ _. HardWareID-like "* PCI *"} | ft Location
Now we have all the network adapters in the server, but which one is it?
What we need is the adapter name, such as the task manager. The following command will give you the information. It is also not applicable to all adapters.
Get-WMIObject Win32_NetworkAdapter | where {$ _. PNPDeviceID-eq $ Adapter. DeviceID}
Let's put the first command into the variable and execute a loop on the second command. To display the result, we will make a simple Write-Host to display the output. The script is displayed as follows:
$ Adapters = Get-WMIObject Win32_PNPSignedDriver | where {$ _. DeviceClass-eq "NET"-and $ _. HardWareID-like "* PCI *"}
Foreach ($ Adapter in $ Adapters ){
$ AdapterName = Get-WMIObject Win32_NetworkAdapter | where {$ _. PNPDeviceID-eq $ Adapter. DeviceID}
Write-Host 'adapter Name: '$ AdapterName. NetConnectionID
Write-Host 'pci BUS: '$ Adapter. Location
Write-Host 'mac Address: '$ AdapterName. MACAddress
Write-Host 'guid: '$ AdapterName. GUID
Write-Host
}
What will happen? Let's take a look!
This is the case. I also added the MAC address and GUID. The macaddress in this example is also used together with the bacscli.exe command line tool of the official website to configure network adapter settings. If needed, GUID can be used to add TcpAckFrequency to the Registry.
Copy and paste to ensure that all single double quotation marks are correct. I hope this article will be useful to you.