I have this PSCustomObject:
$deviceList = Get-CimInstance -ClassName Win32_PnPEntity | Select-Object Name, HardwareID
$pnpDevLs = Get-PnpDevice | Select Object Name, InstanceID
# Loop structure injected here:
$obj = [PSCustomObject]@{
Name = $device.Name
HardwareID = $device.HardwareID
InstanceID = $pnpDev.InstanceID
}
######################
The goal here is to combine the two queries into one table using a looping mechanism of some kind that would allow me to have this information ready.
I should get a united table with the device Friendly Name, HardwareID as an array, and InstanceID.
Get-PnpDevice
is a CIM cmdlet mapped to the Win32_PnPEntity
class - so you're effectively issuing the same query twice!
$devices = Get-PnpDevice |Select-Object -Property Name, HardwareID, InstanceID