mthiha207au
Contributor
Contributor

Get-scsilunpath with VMhost name on output

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

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

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
Contributor
Contributor

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

0 Kudos