VMware Cloud Community
thg_jimleslie
Contributor
Contributor
Jump to solution

Connectring to ESCI CLI via PowerCLI and installing ESXi Addon Software

Hello and thanks for the assistance,

So im currently looking at installing NCM (nimble connection Manager) on a number of ESXi 6.5 hosts. Currently this would require me to:

connect to powercli

enable SSH on ESXi Host

open ESXi CLI to ESX server from putty

install NCM using the command - esxcli software vib install -d http://update.nimblestorage.com/esx6.5/ncm

check install is ok using the command - esxcli software vib list grep nimble

I need some assistance in automating this in Powercli i think this would look something like:

Connect to ESX host - $esxcli = Get-EsxCli -VMHost (Get-VMHost "ESXhostname.domainname.local") -V2 - However could this be automated to be all esx hosts in the vmware cluster?

$esxcli.software.vib.install.-d.http://update.nimblestorage.com/esx6.5/ncm

$esxcli.software.vib.list.grep.nimble

As a test I have run the following:

open powercli connect to vcenter server

$esxcli = Get-EsxCli -VMHost (Get-VMHost "ESXhostname.domainname.local") -V2 - to connect to my ESX via powercli

$esxcli.software.vib.list.grep.vmware - to attempt list any vmware software on that host

but all i get is

************************************************

PowerCLI C:\> $esxcli.software.vib.list

EsxCliMethodElement: list

   Methods:

   --------

   Hashtable CreateArgs()

   VIBSummary[] Invoke(Hashtable args)

   string Help()

***********************************************

I could do with assistance as per below

Am i missing something to generate an out put list of any VMWare software installed on this esxi node?

How can i include all ESX server's circling until all are installed?

how can i output (maybe to csv) what esx nodes have software from nimble installed?

Thanks in advance

Jim

1.0.0.20
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

No, like this

Get-VMHost | ForEach-Object -Process {

    $esxcli = Get-EsxCli -V2 -VMHost $_

    if(-not($esxcli.software.vib.list.Invoke() | where {$_.Name -eq "nimble-ncs"})){

     $esxcli.software.vib.install.Invoke(@{depot='http://update.nimblestorage.com/esx6.5/ncm'})

     Restart-VMHost -VMHost $_ -Evacuate -Confirm:$false -Force

    }

}

The Restart-VMHost cmdlet will take care of the maintenance mode and wait till the node is restarted


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

View solution in original post

Reply
0 Kudos
9 Replies
LucD
Leadership
Leadership
Jump to solution

If you use the V2 switch, you have to call the Invoke method.

$esxcli.software.vib.list.Invoke()

See PowerCLI 6.3 R1: Get-ESXCLI Why the V2? for more details.


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

Reply
0 Kudos
thg_jimleslie
Contributor
Contributor
Jump to solution

that was very helpful in the check if NCM is installed part of the question found this to work and extract to csv:

Get-VMHost |

   ForEach-Object -Process {

   $esxcli = Get-EsxCli -V2 -VMHost $_

   $esxcli.software.vib.list.Invoke() | where {$_.Name -eq "nimble-ncs"} |

  select @{N = 'VMHost'; E = {$esxcli.VMHost.Name}}, Name, Version, CreationDate, InstallDate, Vendor

} | Export-Csv -Path .\ncm.csv -UseCulture -NoTypeInformation

could i also have assistance with creating a script to loop all esx servers in a vcentre cluster and install the NCS software if not already installed?

Thanks

1.0.0.20
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You could do something like this

Get-VMHost | ForEach-Object -Process {

    $esxcli = Get-EsxCli -V2 -VMHost $_

    if(-not($esxcli.software.vib.list.Invoke() | where {$_.Name -eq "nimble-ncs"})){

     $esxcli.software.vib.install.Invoke(@{depot='http://update.nimblestorage.com/esx6.5/ncm'})

    }

}


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

Reply
0 Kudos
thg_jimleslie
Contributor
Contributor
Jump to solution

So would this work to:

1. identify hosts without ncm installed

2.  put host into Maintanence Mode

3. install ncm

4. take host out of Maintanence mode.

Get-VMHost | ForEach-Object -Process {

    $esxcli = Get-EsxCli -V2 -VMHost $_

    if(-not($esxcli.software.vib.list.Invoke() | where {$_.Name -eq "nimble-ncs"})){

     $esxcli.system.maintenanceMode.set.--enable.true

     $esxcli.software.vib.install.Invoke(@{depot='http://update.nimblestorage.com/esx6.5/ncm'})

     $esxcli.system.maintenanceMode.set.--enable.false

    }

}

I have a concern running this, would it wait for the install to complete before taking the host out of maintanance mode again, is there something i need to add at the end of the install line to require powershell to wait for that to finish before moving on and taking the host out of maintanance mode again?

Thanks

Jim

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I don't think you actually need to place the ESXi node in maintenance mode while installing the vib.
It will only be activated after a reboot.
You could schedule that reboot later in the loop with

Restart-VMHost -VMHost $_ -Evacuate -Confirm:$false -Force

It will place the ESXi node in maintenance mode, and hence evacuate all VMs on the node, reboot and after the reboot take the node out of maintenance mode.


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

Reply
0 Kudos
thg_jimleslie
Contributor
Contributor
Jump to solution

Like this?

Get-VMHost | ForEach-Object -Process {

    $esxcli = Get-EsxCli -V2 -VMHost $_

    if(-not($esxcli.software.vib.list.Invoke() | where {$_.Name -eq "nimble-ncs"})){

     $esxcli.system.maintenanceMode.set.--enable.true

     $esxcli.software.vib.install.Invoke(@{depot='http://update.nimblestorage.com/esx6.5/ncm'})

     $esxcli.restart-VMHost.-VMHost.$_.-Evacuate.-Confirm:$false.-Force

    }

}

1.0.0.20
Reply
0 Kudos
thg_jimleslie
Contributor
Contributor
Jump to solution

after a reboot i think the host will stay in maintanence mode so will need to removed from maintanence mode after the reboot:

this then also raises the question, will powershell wait for the reboot process, reconnect to the host and continue from where it left off after the reboot is completed?

Get-VMHost | ForEach-Object -Process {

    $esxcli = Get-EsxCli -V2 -VMHost $_

    if(-not($esxcli.software.vib.list.Invoke() | where {$_.Name -eq "nimble-ncs"})){

     $esxcli.system.maintenanceMode.set.--enable.true

     $esxcli.software.vib.install.Invoke(@{depot='http://update.nimblestorage.com/esx6.5/ncm'})

     $esxcli.restart-VMHost.-VMHost.$_.-Evacuate.-Confirm:$false.-Force

     $esxcli.system.maintenanceMode.set.--enable.false

    }

}

1.0.0.20
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

No, like this

Get-VMHost | ForEach-Object -Process {

    $esxcli = Get-EsxCli -V2 -VMHost $_

    if(-not($esxcli.software.vib.list.Invoke() | where {$_.Name -eq "nimble-ncs"})){

     $esxcli.software.vib.install.Invoke(@{depot='http://update.nimblestorage.com/esx6.5/ncm'})

     Restart-VMHost -VMHost $_ -Evacuate -Confirm:$false -Force

    }

}

The Restart-VMHost cmdlet will take care of the maintenance mode and wait till the node is restarted


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

Reply
0 Kudos
thg_jimleslie
Contributor
Contributor
Jump to solution

Brilliant, thanks for your help

1.0.0.20
Reply
0 Kudos