Automation

 View Only
Expand all | Collapse all

Install .vmexe file using POSH-SSH

LucD

LucDJul 20, 2020 08:54 AM

Pilu1978

Pilu1978Jul 20, 2020 09:06 AM

Pilu1978

Pilu1978Jul 20, 2020 09:46 AM

  • 1.  Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 05:28 AM

    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.



  • 2.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 07:13 AM

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



  • 3.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 07:56 AM

    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:



  • 4.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 08:07 AM

    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?



  • 5.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 08:27 AM

    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



  • 6.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 08:54 AM

    Did you try with the -s parameter?



  • 7.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 09:06 AM

    Yes but same ExitStatus as 6.



  • 8.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 09:10 AM

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



  • 9.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 09:46 AM

    yes



  • 10.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 10:48 AM

    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



  • 11.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 11:50 AM

    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

        }



  • 12.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 11:52 AM

    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'



  • 13.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 12:17 PM

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

    But the path is correct as shown below:



  • 14.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 12:27 PM

    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.



  • 15.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 12:39 PM

    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:



  • 16.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 20, 2020 01:01 PM

    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



  • 17.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 21, 2020 08:11 AM

    I am getting the below error after running this code:



  • 18.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 21, 2020 08:27 AM

    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?



  • 19.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 21, 2020 08:49 AM

    This time getting the below error:



  • 20.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 21, 2020 08:56 AM

    Let me try to install it on another host with this updated code. I will get back to with the result shortly.



  • 21.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 21, 2020 09:31 AM

    It looks as if error code 3 indicates a 'downgrade'.

    Apparently the 'force' flag is required.

    Try adding the -s -f parameters on the call to the vmexe.



  • 22.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 21, 2020 09:34 AM

    I have tried it on another host but giving same error. Firmware is not getting installed.



  • 23.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 21, 2020 09:35 AM

    With the force flag (-f)?



  • 24.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 21, 2020 09:47 AM

    getting below error with -f option



  • 25.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 21, 2020 09:54 AM

    At last its executed after putting semi colon at the end as as shown below:

    $code = @'

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

    '@

    However getting the below after the installation. How to get rid of it.



  • 26.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 21, 2020 11:10 AM

    That looks to be a timeout happening.
    The Invoke-SSHCommand cmdlet has a Timeout parameter, you could try using that.


    I have no clue how long this vmexe is supposed to run.
    How long did it run when you executed it from an interactive session?



  • 27.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 21, 2020 01:22 PM

    It takes around 40 - 60 seconds to complete the installation.



  • 28.  RE: Install .vmexe file using POSH-SSH
    Best Answer

    Posted Jul 21, 2020 01:47 PM

    Did you try adding a TimeOut value?



  • 29.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 21, 2020 03:28 PM

    At last it worked after adding the timeout parameter.  Thanks a lot.



  • 30.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 21, 2020 07:57 AM

    Hi LucD,

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



  • 31.  RE: Install .vmexe file using POSH-SSH

    Posted Jul 21, 2020 08:00 AM

    Did you try that last version I posted?