Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Join two PowerShell Queries into one PSCustomObject Table

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading