Looking to create a quick and easy way to validate that we have multiple pathways to our datastores that we can use when we are updating our Cisco FC Directors or the Cisco FIs. We have a decent size environment spanned across two data centers and three vCenter servers.
I have looked at several scripts that look at the multipathing from a host-centric perspective where I would like to look at it from the datastore centric view. I would like to report from a vCenter server a list of datastores, by name not by naa identifier, then a list of servers that the datastore is mounted to, and then the active pathways for each HBA of the host for the datastore.
Thank you for the help in advance.
Tim
Try something like this
Get-Datastore -PipelineVariable ds |
where{$_.ExtensionData.Summary.MultipleHostAccess} |
ForEach-Object -Process {
Get-VMHost -Datastore $ds -PipelineVariable esx|
ForEach-Object -Process {
$dsLun = $ds.ExtensionData.Info.Vmfs.Extent.DiskName
Get-VMHostHba -VMHost $esx -Type FibreChannel -PipelineVariable hba |
where{$_.Status -eq 'Online'} |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.storage.core.path.list.Invoke() |
where{$dsLun -contains $_.Device -and $_.Adapter -eq $hba.Device} |
Select @{N='Datastore';E={$ds.Name}},
@{N='VMHost';E={$esx.Name}},
@{N='HBA';E={$hba.Device}},
RuntimeName,State
}
}
} | Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
Get-Datastore -PipelineVariable ds |
where{$_.ExtensionData.Summary.MultipleHostAccess} |
ForEach-Object -Process {
Get-VMHost -Datastore $ds -PipelineVariable esx|
ForEach-Object -Process {
$dsLun = $ds.ExtensionData.Info.Vmfs.Extent.DiskName
Get-VMHostHba -VMHost $esx -Type FibreChannel -PipelineVariable hba |
where{$_.Status -eq 'Online'} |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.storage.core.path.list.Invoke() |
where{$dsLun -contains $_.Device -and $_.Adapter -eq $hba.Device} |
Select @{N='Datastore';E={$ds.Name}},
@{N='VMHost';E={$esx.Name}},
@{N='HBA';E={$hba.Device}},
RuntimeName,State
}
}
} | Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am sure you hear this 100 times a day. You are my hero.
Thank you,
Tim
How we can use this in 5.0 environment
Get-Datastore : 7/9/2019 6:06:54 PM Get-Datastore Tagging functionality is supported only on vCenter Server 5.1 and newer. The specified server '10.1.10.12' does not meet these requirements.
At line:1 char:1
+ Get-Datastore -PipelineVariable ds |
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-Datastore], ViError
+ FullyQualifiedErrorId : Util10_SharedParameterHelper_TryValidateServerSupportsTagging_TaggingNotSupported,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetDatastore
Which PowerShell version are you using?
Do a $PSVersionTable
I suspect the PipelineVariable, introduced in PS v4, is causing the issue.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference