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.
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
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...
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
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.
$vm.Config.Hardware.Device | Where {$_ -is [VMware.Vim.VirtualEthernetCard]}
Will return any NIC.
[VMware.Vim.VirtualEthernetCard] is a data type?
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