none
WQL Query for Associators not working as envisaged RRS feed

  • Question

  • Trying to use Associators Of keywork in a WQL query as follows:

    $q = "ASSOCIATORS OF {Win32_LogicalDisk.DeviceID='C:'} WHERE AssocClass = Win32_ComputerSystem"
    Get-CimInstance -Query $q -verbose


    This query should return the same instance as:

    $disk = Get-CimInstance -ClassName Win32_LogicalDisk 
    Get-CimAssociatedInstance -InputObject $disk[0]  –ResultClass Win32_ComputerSystem 

    The latter works fine, but the WQL is not returning anything.

    Clues?



    Thomas Lee <DoctorDNS@Gmail.Com>

    Wednesday, November 4, 2015 9:49 PM
    Moderator

Answers

  • ResultClass!!!

    gwmi -q "ASSOCIATORS OF {Win32_LogicalDisk.DeviceID='C:'} WHERE ResultClass = Win32_ComputerSystem"

    Get-CimAssociatedInstance -InputObject $disk[0]  –ResultClass Win32_ComputerSystem


    \_(ツ)_/


    • Edited by jrv Wednesday, November 4, 2015 10:55 PM
    • Marked as answer by Thomas LeeModerator Thursday, November 5, 2015 12:11 PM
    Wednesday, November 4, 2015 10:53 PM

All replies

  • ResultClass!!!

    gwmi -q "ASSOCIATORS OF {Win32_LogicalDisk.DeviceID='C:'} WHERE ResultClass = Win32_ComputerSystem"

    Get-CimAssociatedInstance -InputObject $disk[0]  –ResultClass Win32_ComputerSystem


    \_(ツ)_/


    • Edited by jrv Wednesday, November 4, 2015 10:55 PM
    • Marked as answer by Thomas LeeModerator Thursday, November 5, 2015 12:11 PM
    Wednesday, November 4, 2015 10:53 PM
  • I knew that...

    Seriously: thanks. The original quote is yet another bit of code on the Internet that is wrong! :=)


    Thomas Lee <DoctorDNS@Gmail.Com>

    Thursday, November 5, 2015 12:12 PM
    Moderator
  • I don't always get those straight.

    $device=[wmi]"Win32_LogicalDisk.DeviceID='C:'"
    $device.GetRelated('Win32_ComputerSystem')


    \_(ツ)_/

    Thursday, November 5, 2015 2:25 PM