Automation

 View Only
  • 1.  stop a service using GET-ESXCLI

    Posted Mar 29, 2020 12:26 PM

    Hello,

    I'd like to use get-esxcli to run the following command, I also need to run it against specific clusters, or maybe by importing from a CSV file please.

    esxcli system wbem set --enable false

    Thank you,



  • 2.  RE: stop a service using GET-ESXCLI

    Posted Mar 29, 2020 02:12 PM

    Try like this

    $esxName = 'MyESx'

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

    $esxcli.system.wbem.set.Invoke(@{enable=$false})

    $esxcli.system.wbem.get.Invoke()



  • 3.  RE: stop a service using GET-ESXCLI

    Posted Mar 29, 2020 02:16 PM

    When you want to run this against all hosts in a cluster, you could do

    Get-Cluster -Name $clusterName | Get-VMHost |

    ForEach-Object -Process {

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

        $esxcli.system.wbem.set.Invoke(@{enable=$false})

        $esxcli.system.wbem.get.Invoke()

    }

    And when you want to select the ESXi nodes via a CSV, you could do.
    This snippet assumes the CSV has a column with the name VMHost.

    Import-Csv -Path .\vmhost.csv -UseCulture |

    ForEach-Object -Process {

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

        $esxcli.system.wbem.set.Invoke(@{enable=$false})

        $esxcli.system.wbem.get.Invoke()

    }



  • 4.  RE: stop a service using GET-ESXCLI

    Posted Mar 29, 2020 02:17 PM

    I will try them tomorrow and let you know the result.

    Be safe!