PowerCLI for Host Storage

Thanks to these excellent blogs:

https://www.virten.net/2014/02/howto-use-esxcli-in-powercli/

http://rvdnieuwendijk.com/2012/08/19/how-to-list-all-the-powercli-esxcli-commands/

 

Following the information presented one can easily perform operations such as listing detached storage devices:

$hosts = Get-Cluster [cluster name] | Get-VMHost

Foreach ($vihost in $hosts) {

Write-Host $vihost

$esxcli = get-vmhost $vihost | Get-EsxCli

$esxcli.storage.core.device.detached.list() | Select DeviceUID | Format-List

}

 

Or you can list the naa ids for all mounted vmfs datastores:

$hosts = Get-Cluster [cluster name] | Get-VMHost

Foreach ($vihost in $hosts) {

Write-Host $vihost

$esxcli = get-vmhost $vihost | Get-EsxCli

$esxcli.storage.vmfs.extent.list() | Select DeviceName | Format-List

}

Leave a Reply

Your email address will not be published. Required fields are marked *