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