VMware Cloud Community
Chensley88
Contributor
Contributor
Jump to solution

Get-View Config.Hardwar.Device Network Adapter Key 4000 resolve to Device Type?

I know about Get-NetworkAdapter before anyone suggests.

Now when using Get-View I drill down on a single record to the network adapter see example in picture attached.

I know the device type is a e1000e I just don't see that listed in the hardware config so I am sure its coded in a hash table.


My best guess is that KEY 4000 = E1000E but I would like a full list of all the device keys so that I can resolve them in my scripts.

All help is welcomed and appreciated thanks.

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The NIC type is in the objecttype.

The following will first list all the types of devices and then filter out the E1000 card

$vm = Get-View -ViewType VirtualMachine -Filter @{'Name'='MyVM'}

$vm.Config.Hardware.Device | %{$_.GetType()}

$vm.Config.Hardware.Device | Where {$_ -is [VMware.Vim.VirtualE1000]}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
6 Replies
sneddo
Hot Shot
Hot Shot
Jump to solution

Key is not the device type, network device keys start at 4000 and are incremented for each NIC (i.e. NIC1 = 4000, NIC2= 4002, etc.)

ControllerID is irrelevant as well as they are all off the same controller. Doesn't look like there is any identifying property that I can see...

LucD
Leadership
Leadership
Jump to solution

The NIC type is in the objecttype.

The following will first list all the types of devices and then filter out the E1000 card

$vm = Get-View -ViewType VirtualMachine -Filter @{'Name'='MyVM'}

$vm.Config.Hardware.Device | %{$_.GetType()}

$vm.Config.Hardware.Device | Where {$_ -is [VMware.Vim.VirtualE1000]}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Chensley88
Contributor
Contributor
Jump to solution

Thanks for the enlightening me the ".getType()"

That answered my question.

For anyone else reading this in the future. I ran

$List = Get-View -ViewType VirtualMachine -Filter @{"Runtime.PowerState" ="poweredOn"}

Then if you want to see the network device type (All I cared about)

$List[1].Config.Hardware.Device[12].gettype()

In the Brackets [ ] I am just selecting specific records, you will need to change / adjust for what you are doing.


Reply
0 Kudos
csteam
Contributor
Contributor
Jump to solution

$vm.Config.Hardware.Device | Where {$_ -is [VMware.Vim.VirtualEthernetCard]}


Will return any NIC.

virtubhuvan
Contributor
Contributor
Jump to solution

[VMware.Vim.VirtualEthernetCard] is a data type?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, it is a vSphere object, accessible through the PowerCLI framework.

See VirtualEthernetCard for further info on the object.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos