Author Posts

March 15, 2017 at 9:44 pm

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

March 15, 2017 at 11:07 pm

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

March 16, 2017 at 4:33 am

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