Matching config file data with WMI output

Welcome Forums General PowerShell Q&A Matching config file data with WMI output

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
2 years, 2 months ago.

  • Author
    Posts
  • #66519

    Participant
    Topics: 4
    Replies: 7
    Points: 0
    Rank: Member

    Hi Everyone,

    I'm a newbie in powershell and got stuck while comparing my configuration file content with output. Please assist. Thanks in advance.

    Problem scenario:

    I've config.xml file in below format.Sample data and script below

    
    
    
    
    
    
    

    $hbas = gwmi -Namespace root/wmi -Class MSFCFibrePortHBAAttributes | select Manufacturer, Model, DriverVersion, Firmware

    Currently, I'm using below logic to check my configuration with above output($hba)
    ## script logic

    foreach (Configuration in OS.Configuration) { ## To parse xml attributes
    foreach ($hba in $hbas) { # we have 4 instance of hba
    $my = $configuration.hba | where {hba.manufacturer -match $_.Manufacturer} |where {hba.model -match $_.model} | where {hba.Driverversion -match $_.Driverversion} | | where {hba.Firmwareversion -match $_.Firmwareversion}
    if ($my) { break }
    }
    if ($my) { break }
    }
    

    ##—————–

    With above code, I was able to successfully figure out whether configuration file settings matches with output($hba) or not and show it to SA's by displaying message that combination is not supported.

    Now, I've new requirement where needs to display specifically the details of output component $hbas (Manufacturer,Model, Driverversion or firmwareversion) as an error that failed to match from config file.

    In real case scenario, we have 10+ 1 on 1 mapping in our configuration file.

    Regards,
    Adarsh

  • #66538

    Keymaster
    Topics: 13
    Replies: 4872
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    Web pages don't like XML :). Consider posting that as a Gist and just inserting the Gist URL here.

    • #66549

      Participant
      Topics: 4
      Replies: 7
      Points: 0
      Rank: Member

      Hi Everyone,

      I'm a newbie in powershell and got stuck while comparing my configuration file content with output. Please assist. Thanks in advance.

      Problem scenario:

      I've config.xml file in below format.Sample data and script below

      xml config file gist url :

      $hbas = gwmi -Namespace root/wmi -Class MSFCFibrePortHBAAttributes | select Manufacturer, Model, DriverVersion, Firmware

      Currently, I'm using below logic to check my configuration with above output($hba)

      ## Script logic below

      foreach (Configuration in OS.Configuration) { ## To parse xml attributes
      foreach ($hba in $hbas) { # we have 4 instance of hba
      $my = $configuration.hba | where {hba.manufacturer -match $_.Manufacturer} |where {hba.model -match $_.model} | where {hba.Driverversion -match $_.Driverversion} | | where {hba.Firmwareversion -match $_.Firmwareversion}
      if ($my) { break }
      }
      if ($my) { break }
      }
      

      With above code, I was able to successfully figure out whether configuration file settings matches with output($hba) or not and show it to users by displaying message that combination is not supported.

      Now, I've new requirement where needs to display specifically the details of output component $hbas (Manufacturer,Model, Driverversion or firmwareversion) as an error that failed to match from config file.

      In real case scenario, we have 10+ 1 on 1 mapping in our configuration file.

      Regards,
      Adarsh

The topic ‘Matching config file data with WMI output’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort