VMware Cloud Community
Pilu1978
Enthusiast
Enthusiast
Jump to solution

Install .vmexe file using POSH-SSH

Hi,

I am trying to automate the HBA firmware installation using Posh-SSH module on my HP Gen8 6.5 hosts. The firmware installer comes in zip format and it contains the following files:

CP032799.exe

CP032799.vmfile

CP032799.xml

payload.json

Readme.txt

So the script will ask for host name and the datastore on which these files are uploaded.

However it is failing to execute the vmexe file. It is telling vmfile not found.

Any help would be appreciated.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Did you try adding a TimeOut value?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
30 Replies
LucD
Leadership
Leadership
Jump to solution

Can you show the script you are using and the errors you are getting?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Pilu1978
Enthusiast
Enthusiast
Jump to solution

Thanks for your reply.

This is the code:

$esxhost = Read-Host "Enter Host Name(FQDN)"

$ds = Read-Host "Enter datatsore path on which drivers are uploaded"

$esxCreds = Get-Credential root

$session = New-SshSession -ComputerName $esxhost -Credential $esxCreds -AcceptKey

$dspath = "/vmfs/volumes/" + $ds

$chmod = "chmod +x " + $dspath + "/" + "CP032799.vmexe"

$vmexe = $dspath + "/CP032799.vmexe"

Invoke-SSHCommand -SSHSession $session -Command $chmod

Invoke-SSHCommand -SSHSession $session -Command $vmexe

Remove-SSHSession -SSHSession $session | Out-Null

I am getting the below out put with ExitStatus as 6:

pastedImage_7.png

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Did you already try running the vmexe from an interactive SSH session?

Are there any prompts?

Are there parameters to be added for a silent run?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Pilu1978
Enthusiast
Enthusiast
Jump to solution

There is no prompt. Just go to the path and type ./

There is no prompt. Just go to the path and type ./CP032799.vmexe and hit enter. It will install. I think we can use -s to run it sliently.

I have got the below link when same is done through scripts. But I find it complex.

https://github.com/PaulGrevink/ESXi_CLIativity

Please check the firmware.plink script how to executes vmexe file using shell script.

Below is the complete link:

ESXi CLIativity – Part 2 | Adventures in a Virtual World

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Did you try with the -s parameter?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Pilu1978
Enthusiast
Enthusiast
Jump to solution

Yes but same ExitStatus as 6.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Does it work when you run the vmexe from an interactive SSH session?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Pilu1978
Enthusiast
Enthusiast
Jump to solution

yes

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Can you run this version?

$esxhost = Read-Host "Enter Host Name(FQDN)"

$ds = Read-Host "Enter datatsore path on which drivers are uploaded"

$esxCreds = Get-Credential root


$session = New-SshSession -ComputerName $esxhost -Credential $esxCreds -AcceptKey


$dspath = "/vmfs/volumes/" + $ds

$code = @'

cd $dspath

ls -l

chmod +x CP032799.vmexe

./CP032799.vmexe -s

'@


$result = Invoke-SSHCommand -SSHSession $session -Command ($ExecutionContext.InvokeCommand.ExpandString($code)) -Verbose

$result | Format-Custom


Remove-SSHSession -SSHSession $session | Out-Null


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Pilu1978
Enthusiast
Enthusiast
Jump to solution

It is giving the below error:

class SshCommand

{

  Output =

    [

    ]

  ExitStatus = 127

  Error = sh: cd: line 1: can't cd to /vmfs/volumes/xxxxxxxxxxx/VIBTEMP/LPFC

  ls: invalid option -- ''

  BusyBox v1.22.1 (2018-07-23 19:34:04 PDT) multi-call binary.

  Usage: ls [-1AaCxdLHRFplinsehrSXvctu] [-w WIDTH] [FILE]...

  List directory contents

        -1      One column output

        -a      Include entries which start with .

        -A      Like -a, but exclude . and ..

        -C      List by columns

        -x      List by lines

        -d      List directory entries instead of contents

        -L      Follow symlinks

        -H      Follow symlinks on command line

        -R      Recurse

        -p      Append / to dir entries

        -F      Append indicator (one of */=@|) to entries

        -l      Long listing format

        -i      List inode numbers

        -n      List numeric UIDs and GIDs instead of names

        -s      List allocated blocks

        -e      List full date and time

        -h      List sizes in human readable format (1K 243M 2G)

        -r      Sort in reverse order

        -S      Sort by size

        -X      Sort by extension

        -v      Sort by version

        -c      With -l: sort by ctime

        -t      With -l: sort by mtime

        -u      With -l: sort by atime

        -w N    Assume the terminal is N columns wide

        --color[={always,never,auto}]   Control coloring

  chmod: CP032799.vmexe: No such file or directory

  sh: ./CP032799.vmexe: not found

  Host = xxxxxxxxxx

  Duration =

    class TimeSpan

    {

      Ticks = 1526292

      Days = 0

      Hours = 0

      Milliseconds = 152

      Minutes = 0

      Seconds = 0

      TotalDays = 1.76654166666667E-06

      TotalHours = 4.2397E-05

      TotalMilliseconds = 152.6292

      TotalMinutes = 0.00254382

      TotalSeconds = 0.1526292

    }

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The cd error seems to confirm the exit code 6, file not found.

Looks like the path is not correct.

The ls error is because you seem to have put 2 dashes instead of 1.

That should be 'ls -l'


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Pilu1978
Enthusiast
Enthusiast
Jump to solution

ls -l error gone after putting in in quotes. Thanks.

But the path is correct as shown below:

pastedImage_0.png

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The 1st error needs to be fixed.

This one.

Error = sh: cd: line 1: can't cd to /vmfs/volumes/xxxxxxxxxxx/VIBTEMP/LPFC

I guess you edited the error message with that 'xxxxxxxxxxxx' string?

Also, I don't understand your remark

ls -l error gone after putting in in quotes.

What exactly do you mean by 'quotes'?

Can you show your adapted script?

The screenshot is from an interactive SSH session.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Pilu1978
Enthusiast
Enthusiast
Jump to solution

The string which is marked with blue is the name of the local datastore which is same with host name.

$esxhost = Read-Host "Enter Host Name(FQDN)"

$ds = Read-Host "Enter datatsore path on which drivers are uploaded"

$esxCreds = Get-Credential root

$session = New-SshSession -ComputerName $esxhost -Credential $esxCreds -AcceptKey

$dspath = "/vmfs/volumes/" + $ds

$code = @'

cd $dspath

'ls -l'

chmod +x CP032799.vmexe

./CP032799.vmexe

'@

$result = Invoke-SSHCommand -SSHSession $session -Command ($ExecutionContext.InvokeCommand.ExpandString($code)) -Verbose

$result | Format-Custom

Remove-SSHSession -SSHSession $session | Out-Null

I am getting the below error after running the above code:

pastedImage_7.png

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Can you try this version?

$esxhost = Read-Host "Enter Host Name(FQDN)"

$ds = Read-Host "Enter datatsore path on which drivers are uploaded"

$esxCreds = Get-Credential root


$session = New-SshSession -ComputerName $esxhost -Credential $esxCreds -AcceptKey


$dspath = "/vmfs/volumes/" + $ds

$code = @'

cd $dspath; ls -l; chmod +x CP032799.vmexe; ./CP032799.vmexe -s

'@


$result = Invoke-SSHCommand -SSHSession $session -Command ($ExecutionContext.InvokeCommand.ExpandString($code)) -Verbose

$result | Format-Custom


Remove-SSHSession -SSHSession $session | Out-Null


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Pilu1978
Enthusiast
Enthusiast
Jump to solution

Hi LucD,

Sorry please let me know if you are looking for more information on this.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Did you try that last version I posted?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Pilu1978
Enthusiast
Enthusiast
Jump to solution

I am getting the below error after running this code:

pastedImage_0.png

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok, looks like we are getting somewhere.

Can you replace these lines

$result = Invoke-SSHCommand -SSHSession $session -Command ($ExecutionContext.InvokeCommand.ExpandString($code)) -Verbose

$result | Format-Custom

with these

$result = Invoke-SSHCommand -SSHSession $session -Command ($ExecutionContext.InvokeCommand.ExpandString($code)) -Verbose

$result.Output

and run it again?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos