Operating System - VMware
1751805 Members
4978 Online
108781 Solutions
New Discussion

Problems using Get-ESXCLI with HPSSACLI

 
Ginolard1
Occasional Visitor

Problems using Get-ESXCLI with HPSSACLI

Running ESXi 5.1 (free version) on a HP DL580 G7

 

I'm trying to use Get-ESXICli to run HPSSACLI commands from Powershell.  When trying to run the following commands I get an InvalidCastException :-

 

$esxcli=get-esxcli

$esxcli.hpssacli.cmd("help")

 

Unable to cast object of type 'System.String' to type 'System.Collections.Generic.Dictionary`2[System.String,System.Object]'.
At line:1 char:1
+ $esxcli.hpssacli.cmd('"-q "controller all show status""')
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], InvalidCastException
    + FullyQualifiedErrorId : System.InvalidCastException

 

Now if look at the method definition for cmd (by running $esxcli.hpssacli) it shows this

 

Methods:
--------
string[] cmd(string cmdopts)

 


That means that it expects to receive a string as a parameter to CMD and then returns a string array called (stupidly) "string[]".  So, the command I'm running is perfectly fine but what is, in fact, being returned is a single string value.  So, Powershell throws an error saying, quite rightly, that it cannot convert a single string to a string array.

 

This seems like a bug to me.  It's expecting a string array but returning a single string.

 

Compare that with the the native ESXICLI List method of the CPU object ($esxcli.hardware.cpu)

 

Methods:
--------
Cpu[] list()

 


That returns a string array called CPU[] when the List method is run and, naturally, this works just fine.

 

So, am I formatting the HPSSACLI incorrectly or is this a bug?  I suspect the latter

1 REPLY 1
Ginolard1
Occasional Visitor

Re: Problems using Get-ESXCLI with HPSSACLI

Solved it!!

It's not a bug in the HPSSACLI , it's in the PowerCLI module. The latest release (r2) fixes it