none
Combine output from WMIC -> NIC & NICconfig

Answers

  • Can we combine the tabular output of wmic nic & wmic nicconfig ?


    yup


    The tables are not the same.  Combing tables requires that the tables have the same structure.

    If you are refereingto a relational query then it wwoul be better to use PowerShell which can build complex objects and generate hierarchical output.  WMIC cannot do this and hacking it with a batch file would get ugly.

    VBS could do it but would take a lot more code than PowerShell.

     


    jv
    • Marked as answer by yup. _ Tuesday, January 10, 2012 11:02 PM
    Tuesday, January 10, 2012 10:42 PM

All replies

  • Hi,

    What do you want to do?

    Bill

    Tuesday, January 10, 2012 10:36 PM
    Moderator
  • Can we combine the tabular output of wmic nic & wmic nicconfig ?


    yup


    The tables are not the same.  Combing tables requires that the tables have the same structure.

    If you are refereingto a relational query then it wwoul be better to use PowerShell which can build complex objects and generate hierarchical output.  WMIC cannot do this and hacking it with a batch file would get ugly.

    VBS could do it but would take a lot more code than PowerShell.

     


    jv
    • Marked as answer by yup. _ Tuesday, January 10, 2012 11:02 PM
    Tuesday, January 10, 2012 10:42 PM
  • Got you, will be using PSH if needed but thats heavy..... there's no other way it seems.


    yup
    Tuesday, January 10, 2012 10:51 PM
  • This will combine the two classes with the AssociatorsOf thingy.  I'm quite pleased with this:

    $ids = Get-WmiObject -Class win32_networkadapter | select -ExpandProperty deviceID 
    foreach ($id in $ids) {
        Get-WMIObject -Query "Associators Of {Win32_NetworkAdapter.DeviceID=$id} WHERE ResultClass=Win32_NetworkAdapterConfiguration" | fl *
    }
    


    Grant Ward

    What's new in Powershell 3.0 (Technet Wiki)

    Tuesday, January 10, 2012 11:26 PM
  • This will combine the two classes with the AssociatorsOf thingy.  I'm quite pleased with this:

     

    $ids = Get-WmiObject -Class win32_networkadapter | select -ExpandProperty deviceID 
    foreach ($id in $ids) {
        Get-WMIObject -Query "Associators Of {Win32_NetworkAdapter.DeviceID=$id} WHERE ResultClass=Win32_NetworkAdapterConfiguration" | fl *
    }
    

     


    Grant Ward

    What's new in Powershell 3.0 (Technet Wiki)

    Does not comnine. It just uses one to look up the other.  Add all of the associated items to the original item and you have a decoded class.

     


    jv
    Tuesday, January 10, 2012 11:35 PM
  • I thought it did some kind of join.  If not, what's the use of using Associators of?  I could just as well have queried the win32_networkadapterconfiguration class directly.
    Grant Ward

    What's new in Powershell 3.0 (Technet Wiki)

    Tuesday, January 10, 2012 11:43 PM
  • You can on;ly get teh adpather by name from teh adapter class.  That is how we find the configuration.  It does not do a join.  YOU have to joinn the data or, ar least, create the joined output.

     


    jv
    Wednesday, January 11, 2012 12:22 AM
  • Ok, here I've created a joined output of related data for all network adapters:

    gwmi -Class win32_networkadapter | % {
        Write-Host "Network Adapter" -ForegroundColor Green
        $_
        Write-Host "Network Adapter Configuration" -ForegroundColor green
        gwmi -Class win32_networkadapterconfiguration -Filter "Description='$($_.name)'" 
        Write-Host "=================================================================================" -ForegroundColor DarkGray
        }
    
    


    Grant Ward

    What's new in Powershell 3.0 (Technet Wiki)

    Wednesday, January 11, 2012 3:52 PM
  • Add properties from both classes to new object that will have all of the unique items of both classes.  That is what is meant by a join.  YOu are just outputting some properties to teh screen which is not useful down the line.  Also, it does not account for multiple child classes.

     


    jv
    Wednesday, January 11, 2012 4:06 PM
  • Well, it seems like WMI is not designed for true joins.  This is why SQL exists, I suppose.
    Grant Ward

    What's new in Powershell 3.0 (Technet Wiki)


    • Edited by Bigteddy Wednesday, January 11, 2012 4:14 PM
    Wednesday, January 11, 2012 4:14 PM
  • Well, it seems like WMI is not designed for true joins.  This is why SQL exists, I suppose.
    Grant Ward

    What's new in Powershell 3.0 (Technet Wiki)



    It is not SQL and it does not support Joins of any kind.  WQL will just look up the instances of a class or teh relations or associators of a class.  It does not join the two in any way.

    select * from table1,table2 where table1.id=table2.id

    is a join and it will brong back all columns from both tables.

    WQL can only ever see one class. 

    WQL AssociatorsOf can bring back all associated objects but the can only be listed separately.  That is not a join.

     


    jv
    Wednesday, January 11, 2012 4:32 PM