VMware Cloud Community
mthiha207au
Enthusiast
Enthusiast
Jump to solution

Get-scsilunpath with VMhost name on output

Dear All,

I am still new to PowerCLI. My goal is to find death luns path in all the hosts.

I can use this command  Get-VMHost  | Get-ScsiLun  | Get-scsilunpath | Where {$_.state -eq “Dead”}. This will give me nice the output like this. But No VMhost name.

Name                SanID          State          Preferred

-------               -------           ------          ----------

vmhba.xxx       xx.xx.xx       Dead           True

How can I have another column that includes hostname?

Thank you!

Max

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can use the PipelineVariable, that allows you store a pipeline object.

Something like this for example

Get-VMHost -PipelineVariable esx  | Get-ScsiLun -LunType disk | Get-scsilunpath | Where {$_.state -eq “Dead”} |

Select @{N='VMHost';E={$esx.Name}},Name,ScsiCanonicalName,State


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

You can use the PipelineVariable, that allows you store a pipeline object.

Something like this for example

Get-VMHost -PipelineVariable esx  | Get-ScsiLun -LunType disk | Get-scsilunpath | Where {$_.state -eq “Dead”} |

Select @{N='VMHost';E={$esx.Name}},Name,ScsiCanonicalName,State


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

mthiha207au
Enthusiast
Enthusiast
Jump to solution

Thanks LucD. This works like a charm!

Here is the good blog to learn more on -PipelineVariable .

PowerShell V4 – PipelineVariable Common Parameter | Keith Hill's Blog

Reply
0 Kudos