jadewith
(Fresh Scripter)
2014-08-14 01:15 AM
preserving hexadecimal results

Hey guys,

I am trying to pull the fiber channel information from a server and have run into a wall. I can get all the information, however the pwwn's don't display correctly when printed.
here's my code:
 Code:
$servername='mysserver'

$oWbemServices = GetObject("winmgmts://$servername/root/wmi")
$enumSetAdapters = $oWbemServices.InstancesOf("MSFC_FCAdapterHBAAttributes")
$enumSetPorts = $oWbemServices.InstancesOf("MSFC_FibrePortHBAAttributes")
$nIndex = 0
For Each $oEltAdapter In $enumSetAdapters
For Each $oEltPort In $enumSetPorts
If ($oEltAdapter.InstanceName = $oEltPort.InstanceName)  
 " Model: " + $oEltAdapter.Model ?
 " HardwareVersion: " + $oEltAdapter.HardwareVersion ?
 " DriverVersion: " + $oEltAdapter.DriverVersion ?
 " Status: " + $oEltAdapter.HBAStatus ?
 " node_wwn: "
For Each $piece In $oEltAdapter.NodeWWN
  $piece ':'
Next
 ? " port_wwn: "
For Each $piece In $oEltPort.Attributes.PortWWN 
	$piece ':'	
Next
?
$nIndex = $nIndex + 1
EndIf
Next ' $oEltPort'
Next ' $oEltAdapter'


the results of the piece that I want comes out like so:
port_wwn: 33:0:0:36:255:91:208:99:

which is the decimal equivalent of the hexadecimal value that I want:
21:00:00:24:ff:5b:d0:62

How do I make it display correctly?


AllenAdministrator
(KiX Supporter)
2014-08-14 01:29 AM
Re: preserving hexadecimal results

 Code:
$num=split("33:0:0:36:255:91:208:99",":")
for $i=0 to ubound($num)
  $num[$i]=dectohex($num[$i])
next
$hex=join($num,":")

? $hex


AllenAdministrator
(KiX Supporter)
2014-08-14 01:33 AM
Re: preserving hexadecimal results

Or

 Code:
For Each $piece In $oEltPort.Attributes.PortWWN 
	dectohex($piece) +  ':'	
Next


jadewith
(Fresh Scripter)
2014-08-14 01:40 PM
Re: preserving hexadecimal results

I swear I tried that!!!!!!

obviously not because it worked perfectly!

Thanks Allen


Glenn BarnasAdministrator
(KiX Supporter)
2014-08-14 02:09 PM
Re: preserving hexadecimal results

Jadewith,

I can see a use for this.. I better find a GetFcHBA() UDF posted in the UDFs section in the next couple of days! ;\)

Just return an array instead of displaying the data.

Glenn


jadewith
(Fresh Scripter)
2014-08-16 02:01 AM
Re: preserving hexadecimal results

Dang it Glenn!!! OK... I'm working on it.

Glenn BarnasAdministrator
(KiX Supporter)
2014-08-16 12:52 PM
Re: preserving hexadecimal results

Let us know if you need any help with the UDF.. it would be nice to see some new blood in that forum! \:D

jadewith
(Fresh Scripter)
2014-08-18 06:13 AM
Re: preserving hexadecimal results

OK Glenn, ye ask and ye shall receive!
UDF GetHBAinfo()


Glenn BarnasAdministrator
(KiX Supporter)
2014-08-18 12:39 PM
Re: preserving hexadecimal results

Nice - I'll give it a try when I get home tonight..

Glenn


NTDOCAdministrator
(KiX Master)
2014-08-20 01:30 AM
Re: preserving hexadecimal results

Thank you for the UDF and input. As it would appear the current version does not fully comply with UDF standards please review the suggestions and either update the UDF or let us know and we can move it to the Scripting forum until it is ready.

Thanks again


Glenn BarnasAdministrator
(KiX Supporter)
2014-08-20 02:00 AM
Re: preserving hexadecimal results

Doc - we've discussed this offline and Jason is working on an update that will be compliant.. \:D

Glenn


NTDOCAdministrator
(KiX Master)
2014-08-20 09:04 PM
Re: preserving hexadecimal results

Great - thanks Glenn