Automation

 View Only
  • 1.  Get-ESXCli get device smart info

    Posted Oct 27, 2020 02:32 PM

    When manually pulling the smart info using the NAA Identifier it works. But when it is stored in a variable, it doesn't. I'd like to be able to pull the smart info for all the devices from all the hosts in a cluster.

    Thanks



  • 2.  RE: Get-ESXCli get device smart info

    Posted Oct 27, 2020 03:17 PM

    When you place a variable between single quotes, there will be no substitution.

    Place $device between double quotes.



  • 3.  RE: Get-ESXCli get device smart info

    Posted Oct 27, 2020 04:52 PM

    Double quotes worked. Thanks LucD​.

    Would you mind helping me get this working? Like I said earlier, I'm trying to pull the smart info from every host in the cluster. The following snippet does work, but I'd like to add the hostname and NAA identifier to the list.

    Get-VMhost -PipelineVariable esx |

    ForEach-Object -Process {

        $EsxCli = Get-EsxCli -VMHost $esx -V2

        ($esxcli.storage.core.device.list.Invoke() | Where {$_.ThinProvisioningStatus -eq "yes"}) | Select Device |

        ForEach-Object -Process {

            $esxcli.storage.core.device.smart.get.Invoke(@{devicename = $_.device})

        }

    } | Out-GridView



  • 4.  RE: Get-ESXCli get device smart info
    Best Answer

    Posted Oct 27, 2020 05:19 PM

    You could do something like this

    Get-VMhost -PipelineVariable esx |

    ForEach-Object -Process {

        $EsxCli = Get-EsxCli -VMHost $esx -V2

        $esxcli.storage.core.device.list.Invoke() | Where {$_.ThinProvisioningStatus -eq "yes"} |

        ForEach-Object -Process {

            $dev = $_.device

            $esxcli.storage.core.device.smart.get.Invoke(@{devicename = $dev}) |

            Select @{N='VMHost';E={$esxcli.VMHost.Name}},

                @{N='Device';E={$dev}},*

        }

    } | Out-GridView