VMware Cloud Community
imveldi
Contributor
Contributor

Execute ESXCLI command via PowerCLi

Hello All,

I need help to execute below against a cluster using Power CLI, Please help.

esxcli storage core device detached remove -d NAA_ID

Thank you,

Vamsi.

0 Kudos
1 Reply
piercj2
Enthusiast
Enthusiast

Hi Vamsi,

It looks like you are trying to remove a bunch of detached LUNs from your cluster.

obviously, I don't want to do this in my live environment but, you may be able to modify the below to do what you want

$cluster = (read-host "Enter the Cluster name")

foreach ($h in (get-cluster $cluster | get-vmhost)) {

$esxcli = get-esxcli -vmhost $h

$esxcli.storage.core.device.detached.list()

$esxcli.storage.core.device.detached.remove()

}

careful using this for obvious reasons.

If you'd prefer to test from shell, try

$h = YourHostNameHere

$esxcli = get-esxcli -vmhost $h

$esxcli.storage.core.device.detached.list()

$esxcli.storage.core.device.detached.remove()

To see what methods / properties are available to you, use

$esxcli | gm

0 Kudos