Powered by System Center
Powershell: Collect NIC PCI bus info for automation
When doing a deployment of a Hyper-V cluster consequently configuring the networking can be a pain in the you know what. Different vendors or changing hardware layouts are only two examples that can make automated deployment challenging. This blog will explain how you can collect information about which network adapter is located at what PCI bus with Powershell. This information you can then later use to rename network adapter, teaming, changing network adapter settings etc etc.
Let first start by collecting some information of the present network adapters. The Powershell command to do this is something like this:
| Get-WMIObject Win32_PNPSignedDriver | where { $_.DeviceClass -eq “NET” -and $_.HardWareID -like “*PCI*”} |
The result will look something like shown below:
In the output we can find the location of the network adapters. You probably can imagine when having 12 network adapters in your server this isn’t very useful. So lets only collect the PCI bus information by adding | ft Location to the Powershell command.
| Get-WMIObject Win32_PNPSignedDriver | where { $_.DeviceClass -eq “NET” -and $_.HardWareID -like “*PCI*”} | ft Location |
So now we have all the Location of the network adapters present in the server but which is which?
What we need is the Adapter Name as shown in for example the Task Manager. With the command shown below you will get this information. Again for all adapters. Not very useful.
| Get-WMIObject Win32_NetworkAdapter | where { $_.PNPDeviceID -eq $Adapter.DeviceID } |
Let’s put the first command in a variable and do a loop with the second command. To display the results we do a simple Write-Host to show the output. The script will then look like this.
| $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 } |
The result? Look below. ![]()
And voila. I added also the MAC address and the GUID. The MAC address for instance cab be used in combination with Broadcom’s BACScli.exe command line utility to configure network adapter settings. The GUID can be used to add the TcpAckFrequency to the registry if needed.
When copy paste make sure all single and double quotes are correct.
Hopefully you’ll find this blog post useful. Have fun with it!
| Print article | This entry was posted by Maarten Wijsman on February 24, 2012 at 19:34, and is filed under Maarten Wijsman. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
No trackbacks yet.
Connecting System Center 2012 SP1 App Controller to System Center 2012 SP1 Service Provider Foundation – 2 Scenarios
about 1 week ago - 3 comments
Recently I posted a blog series on enabling the Cloud OS with Windows Server and System Center for Hosting Service Providers that consists of the following parts Installing and configuring System Center Service Provider Foundation Installing and configuring Windows Azure for Windows Server – Part 1 Installing and configuring Windows Azure for Windows Server –…
Set Cluster Live Migration Settings
about 2 months ago - 1 comment
Today we, Paul Huijbregts and I, resolved one of the last hurdles in finalizing our automated cluster installation script. This hurdle was to change the priority of the Live Migration settings when creating a Hyper-V cluster. To change this priority we first tried to use the Set-VMMigrationNetwork PowerShell command. Unfortunately this command can only be…
MVMC Automation Toolkit (MAT)
about 2 months ago - No comments
In one of the break-out session at the Microsoft Management Summit 2013, which was held last week, an automation toolkit was shown to migrate virtual machines from “the other guys” to Hyper-V. The toolkit makes use of Microsoft Virtual Machine Converter and is part of the Solution Accelerator tools. The Microsoft Virtual Machine Converter provides…
Removing a non-existent VMM Library Server
about 4 months ago - 1 comment
I admit, you don’t have to remove a non-existent VMM Library Server everyday, but today happened to be such a day. Let me explain what happened. In addition to a SQL Server 2012 AllwaysOn cluster for the VMM database and a VMM 2012 SP1 Failover Cluster, I wanted to also make the VMM Library Server…
NIC Teaming, Hyper-V switch, QoS and actual performance | part 4 – Traffic classes
about 5 months ago - 4 comments
This blog series consists of four parts NIC Teaming, Hyper-V switch, QoS and actual performance | part 1 – Theory NIC Teaming, Hyper-V switch, QoS and actual performance | part 2 – Preparing the lab NIC Teaming, Hyper-V switch, QoS and actual performance | part 3 – Performance NIC Teaming, Hyper-V switch, QoS and actual…
NIC Teaming, Hyper-V switch, QoS and actual performance | part 3 – Performance
about 5 months ago - 5 comments
This blog series consists of four parts NIC Teaming, Hyper-V switch, QoS and actual performance | part 1 – Theory NIC Teaming, Hyper-V switch, QoS and actual performance | part 2 – Preparing the lab NIC Teaming, Hyper-V switch, QoS and actual performance | part 3 – Performance NIC Teaming, Hyper-V switch, QoS and actual…
NIC Teaming, Hyper-V switch, QoS and actual performance | part 2 – Preparing the lab
about 5 months ago - 3 comments
This blog series consists of four parts NIC Teaming, Hyper-V switch, QoS and actual performance | part 1 – Theory NIC Teaming, Hyper-V switch, QoS and actual performance | part 2 – Preparing the lab NIC Teaming, Hyper-V switch, QoS and actual performance | part 3 – Performance NIC Teaming, Hyper-V switch, QoS and actual…
NIC Teaming, Hyper-V switch, QoS and actual performance | part 1 – Theory
about 5 months ago - 16 comments
This blog series consists of four parts NIC Teaming, Hyper-V switch, QoS and actual performance | part 1 – Theory NIC Teaming, Hyper-V switch, QoS and actual performance | part 2 – Preparing the lab NIC Teaming, Hyper-V switch, QoS and actual performance | part 3 – Performance NIC Teaming, Hyper-V switch, QoS and actual…
MS Christmas present: SMI-S Storage Provider for iSCSI Target Server
about 5 months ago - 5 comments
It is only several days since Microsoft made the final bits of System Center 2012 SP1 available, although for a relatively limited audience. If you have a TechNet or MSDN subscription, you have access to SP1 now. All others have to wait till general availability in the course of January 2013. One of my fellow…
Moving Core Cluster Resources in a Windows Sever 2012 Hyper-V Cluster
about 9 months ago - No comments
In Windows Server 2008 R2 it was not possible to move the Core Cluster Resources via Cluster Failover Manager (FCM). When performing maintenance on a cluster node, I prefer not only to evacuate all running guests on that node, but also the CSV disks which are owned by that node. If the Cluster Resource Group…









Twitter
RSS
about 1 year ago
very good stuff… makes automation really easy
about 1 year ago
Very useful. Last year it took me forever to mappout my blade server ports to each nic, so that i could assign the cards to the HYper-V cluster vlan, SAN vlan or the main LAN vlan.
http://en.community.dell.com/techcenter/virtualization/w/wiki/3018.aspx
http://mrshannon.wordpress.com/2010/01/13/jumbo-frames-on-hyper-v-server/?replytocom=8#respond