VMware Cloud Community
MRoushdy
Hot Shot
Hot Shot

stop a service using GET-ESXCLI

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,

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

Try like this

$esxName = 'MyESx'

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

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

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


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

Reply
0 Kudos
LucD
Leadership
Leadership

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()

}


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

Reply
0 Kudos
MRoushdy
Hot Shot
Hot Shot

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

Be safe!

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
Reply
0 Kudos