VMware Cloud Community
CannibalDuck
Contributor
Contributor
Jump to solution

Get VMHost devices, targets and paths list

Hello again. Because of mistake of out network engeneers I need to get all devices, targets and paths VMHost looking at. Is there any script to do this?

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The sample script I gave doesn't show all the properties that are available from Get-ScsiLun and Get-ScsiLunPath.

Which specific properties from $esxcli.storage.core.path.list() do you want to get in the output?


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

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

You could try something like this

Get-VMHost -PipelineVariable esx | Get-ScsiLun -LunType disk -PipelineVariable lun | Get-ScsiLunPath |

Select @{N='ESX';E={$esx.Name}},

    @{N='LUN';E={$lun.CanonicalName}},

    LunPath,State


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

0 Kudos
CannibalDuck
Contributor
Contributor
Jump to solution

Get-VMHost <vmhost> -PipelineVariable esx | Get-ScsiLun -LunType disk -PipelineVariable lun | Get-ScsiLunPath |

Select @{N='ESX';E={$esx.Name}}, @{N='LUN';E={$lun.CanonicalName}}, LunPath, State, @{n='WWN';e={

    $wwn = Get-VMhost $esx | Get-VMHostHBA -Type FibreChannel | select  @{N="WWN";E={"{0:X}" -f $_.PortWorldWideName}} | select -ExpandProperty WWN

    if ($_.LunPath -like "*vmhba1*"){

     

        $wwn[0]

    }else{

     

        $wwn[1]

    }

}

}

Works fine, thanks, LucD Smiley Happy

How can I look deeper and get the full path information like esxcli storage core path list command?

UID: <adapter id>+<target id>+<LUN canonical name>

Runtime Name: <LDEV>
Device: <naa>
Adapter: vmhba0

Target: <target number>

LUN: <LUN id>

State: active

Transport: fc

Adapter Identifier: <adapter ID>

Target Identifier: <target ID>

Adapter Transport Details: WWNN: <why not?> WWPN: <...>

Target Transport Details: WWNN: <...> WWPN: <...>

0 Kudos
LucD
Leadership
Leadership
Jump to solution

The sample script I gave doesn't show all the properties that are available from Get-ScsiLun and Get-ScsiLunPath.

Which specific properties from $esxcli.storage.core.path.list() do you want to get in the output?


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

0 Kudos
CannibalDuck
Contributor
Contributor
Jump to solution

*UPD

got it. $esxcli.storage.core is the key Smiley Happy

Thanks for the help.

Btw, what's the tag for the script code to display normally?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

On the code question, basically in the VMTN editor you can switch to HTML mode, and then it's a matter of copying code from your editor as HTML.

Most editors support that nowadays, if not there are add-ons as well.

I did a document on that see Some ways to enter PowerCLI code under the new forum SW


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

0 Kudos