Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


Sign in to follow this  
buddy

PCI BUSNUMBER X, Device X, Function X

Recommended Posts

Hello all,

how can i get the PCI BUSNUMBER X, Device X, Function X of networkcards

automatic to write the unattend.txt dynamicly, if I have two or more network cards?

Is there a way to do it with wmi (vbscript) or the devcon.exe utility or other reskit utility from microsoft?

I only found it in registry

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI\VEN_1039&DEV_0900&SUBSYS_0A141019&REV_90\3&61aaa01&0&18

in LocationInformation = PCI bus 0, device 3, function 0

There must be a simple way to do it?

I tried it with the following wmi class Win32_PnPSignedDriver.

bye

Buddy

Share this post


Link to post
Share on other sites

I used to hard code it based on the servers I support. But that got ugly.

Now we use a custom application that breaks out all that information and writes it to a reg key in PE.

HKLM\SOFTWARE\MYDATEA\Adapter 1 - All the values I need

HKLM\SOFTWARE\MYDATEA\Adapter 2 - All the values I need

HKLM\SOFTWARE\MYDATEA\Adapter 3 - All the values I need

I just read the key i need.

Chris

Share this post


Link to post
Share on other sites

I'd recommend getting the MAC Address using WMI and then using that value with the NetCardAddress Setting in the unattend.txt.

To get the Mac Address use the MacAddress property from the Win32_NetworkAdapterConfiguration object)

You can then insert this value directly into your unattend.txt like below:

NetCardAddress=00:00:00:00:00

And when you use the NetCardAddress Setting, you don't have to use the PCI Bus, Device, and Function Number settings to distinguish which card you are using. :)

Good Luck!

captcalc

Share this post


Link to post
Share on other sites

In newer Windows versions (since Windows Vista, I guess) the same information is accessible through WMI:

PS C:\Users\Administrator> (gwmi win32_pnpEntity -Filter 'manufacturer like "Red Hat%"')[5].getDeviceProperties().deviceproperties | ft keyName,data

keyName                                        data
-------                                        ----
DEVPKEY_Device_DeviceDesc                      Red Hat VirtIO Ethernet Adapter
DEVPKEY_Device_HardwareIds                     {PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00, PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4, PCI\VEN_1AF4&DEV_1000&CC_020000, PCI\VEN_1AF4&DEV_1000&CC_0200}
DEVPKEY_Device_CompatibleIds                   {PCI\VEN_1AF4&DEV_1000&REV_00, PCI\VEN_1AF4&DEV_1000, PCI\VEN_1AF4&CC_020000, PCI\VEN_1AF4&CC_0200...}
DEVPKEY_Device_Service                         netkvm
DEVPKEY_Device_Class                           Net
DEVPKEY_Device_ClassGuid                       {4D36E972-E325-11CE-BFC1-08002BE10318}
DEVPKEY_Device_Driver                          {4d36e972-e325-11ce-bfc1-08002be10318}\0006
DEVPKEY_Device_ConfigFlags                     0
DEVPKEY_Device_Manufacturer                    Red Hat, Inc.
DEVPKEY_Device_FriendlyName                    Red Hat VirtIO Ethernet Adapter #6
DEVPKEY_Device_LocationInfo                    PCI bus 0, device 17, function 0
DEVPKEY_Device_PDOName                         \Device\NTPNP_PCI0011
DEVPKEY_Device_Capabilities                    0
DEVPKEY_Device_BusTypeGuid                     {C8EBDFB0-B510-11D0-80E5-00A0C92542E3}
DEVPKEY_Device_LegacyBusType                   5
DEVPKEY_Device_BusNumber                       0
DEVPKEY_Device_EnumeratorName                  PCI
DEVPKEY_Device_Address                         1114112
DEVPKEY_Device_PowerData                       {56, 0, 0, 0...}
DEVPKEY_Device_RemovalPolicy                   1
DEVPKEY_Device_RemovalPolicyDefault            1
DEVPKEY_Device_InstallState                    0
DEVPKEY_Device_BaseContainerId                 {00000000-0000-0000-FFFF-FFFFFFFFFFFF}
DEVPKEY_NAME                                   Red Hat VirtIO Ethernet Adapter #6
DEVPKEY_Device_InstanceId                      PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&88
DEVPKEY_Device_DevNodeStatus                   25174026
DEVPKEY_Device_ProblemCode                     0
DEVPKEY_Device_Parent                          ACPI\PNP0A03\0
DEVPKEY_Device_Siblings                        {PCI\VEN_8086&DEV_1237&SUBSYS_00000000&REV_02\3&267a616a&0&00, PCI\VEN_8086&DEV_7000&SUBSYS_00000000&REV_00\3&267a616a&0&08, PCI\VEN_80EE&DEV_BEEF&SUBSYS_00000000&REV_00\3&267a616a&0&10, PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267a616a&0&18...}
DEVPKEY_Device_SafeRemovalRequired             False
DEVPKEY_Device_ContainerId                     {00000000-0000-0000-FFFF-FFFFFFFFFFFF}
DEVPKEY_Device_IsPresent                       True
DEVPKEY_Device_HasProblem                      False
{83DA6326-97A6-4088-9453-A1923F573B29} 15      True
DEVPKEY_Device_IsRebootRequired                False
DEVPKEY_Device_ReportedDeviceIdsHash           1342956424
DEVPKEY_Device_InLocalMachineContainer         True
DEVPKEY_Device_Stack                           {\Driver\netkvm, \Driver\pci}
{A8B865DD-2E3D-4094-AD97-E593A70C75D6} 26      False
{3464F7A4-2444-40B1-980A-E0903CB6D912} 10      2
DEVPKEY_PciDevice_DeviceType                   0
DEVPKEY_PciDevice_CurrentSpeedAndMode          0
DEVPKEY_PciDevice_BaseClass                    2
DEVPKEY_PciDevice_SubClass                     0
DEVPKEY_PciDevice_ProgIf                       0
DEVPKEY_PciDevice_InterruptSupport             1
DEVPKEY_PciDevice_BarTypes                     1
DEVPKEY_PciDevice_S0WakeupSupported            True
DEVPKEY_PciDevice_RequiresReservedMemoryRegion False
DEVPKEY_Device_BusReportedDeviceDesc           Ethernet Controller
DEVPKEY_Device_ConfigurationId                 oem2.inf:PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00,kvmnet6.ndi
{80497100-8C73-48B9-AAD9-CE387E19C56E} 6       6
{83DA6326-97A6-4088-9453-A1923F573B29} 3       oem2.inf:664f42767dbc5606:kvmnet6.ndi:100.74.104.14100:PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00
{83DA6326-97A6-4088-9453-A1923F573B29} 10      ACPI\PNP0A03\0
{83DA6326-97A6-4088-9453-A1923F573B29} 18      0
DEVPKEY_Device_InstallDate                     20190404180902.239000-420
DEVPKEY_Device_FirstInstallDate                20190404174841.372159-420
DEVPKEY_Device_LastArrivalDate                 20190416120950.133039-420
DEVPKEY_Device_LocationPaths                   {PCIROOT(0)#PCI(1100), ACPI(_SB_)#ACPI(PCI0)#PCI(1100)}
DEVPKEY_Device_DriverDate                      20170718170000.000000-420
DEVPKEY_Device_DriverVersion                   100.74.104.14100
DEVPKEY_Device_DriverDesc                      Red Hat VirtIO Ethernet Adapter
DEVPKEY_Device_DriverInfPath                   oem2.inf
DEVPKEY_Device_DriverInfSection                kvmnet6.ndi
DEVPKEY_Device_MatchingDeviceId                PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00
DEVPKEY_Device_DriverProvider                  Red Hat, Inc.
DEVPKEY_Device_DriverRank                      16711680
{F0E20F09-D97A-49A9-8046-BB6E22E6BB2E} 2       {1, 0, 0, 0...}

(This device is taken as an example.)

Besides Location, device and function numbers are encoded in Address variable, it's a DWORD, the higher word of which is device number and the lower one is function:

PS C:\Users\Administrator> (gwmi Win32_Bus -Filter 'DeviceID like "PCI%"').GetRelated('Win32_PnPEntity').GetDeviceProperties('DEVPKEY_Device_Address').deviceProperties | ft DeviceID,keyName,{$_.data -shr 16},{$_.data -band 0xFFFF}

DeviceID                                                     keyName                $_.data -shr 16 $_.data -band 0xFFFF
--------                                                     -------                --------------- --------------------
PCI\VEN_8086&DEV_7000&SUBSYS_00000000&REV_00\3&267A616A&0&08 DEVPKEY_Device_Address               1                    0
PCI\VEN_80EE&DEV_CAFE&SUBSYS_00000000&REV_00\3&267A616A&0&20 DEVPKEY_Device_Address               4                    0
PCI\VEN_8086&DEV_2829&SUBSYS_00000000&REV_02\3&267A616A&0&68 DEVPKEY_Device_Address              13                    0
PCI\VEN_8086&DEV_1237&SUBSYS_00000000&REV_02\3&267A616A&0&00 DEVPKEY_Device_Address               0                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&18 DEVPKEY_Device_Address               3                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&40 DEVPKEY_Device_Address               8                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&48 DEVPKEY_Device_Address               9                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&50 DEVPKEY_Device_Address              10                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&80 DEVPKEY_Device_Address              16                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&88 DEVPKEY_Device_Address              17                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&90 DEVPKEY_Device_Address              18                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&98 DEVPKEY_Device_Address              19                    0
PCI\VEN_80EE&DEV_BEEF&SUBSYS_00000000&REV_00\3&267A616A&0&10 DEVPKEY_Device_Address               2                    0

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...