VMware Cloud Community
winsolo
Enthusiast
Enthusiast
Jump to solution

Get-ESXCli get device smart info

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.

Snag_634c279.png

Snag_637e6bb.png

Thanks

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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


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

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

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

Place $device between double quotes.


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

0 Kudos
winsolo
Enthusiast
Enthusiast
Jump to solution

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

Snag_6b9bf36.png

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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


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

0 Kudos