61 lines
2.0 KiB
PowerShell
61 lines
2.0 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Retrieves HBA (Host Bus Adapter) device information, including WWN (World Wide Name) and WWP (World Wide Port Name), for specified VMware ESXi hosts.
|
|
|
|
.DESCRIPTION
|
|
This function connects to one or more VMware ESXi hosts and gathers detailed information about their HBA devices. The information collected includes the device name, WWN, WWP, and other relevant properties. This is useful for inventory, troubleshooting, or auditing storage connectivity in a VMware environment.
|
|
|
|
.PARAMETER VMHost
|
|
Specifies the ESXi host(s) from which to retrieve HBA information. Accepts one or more host names or objects.
|
|
|
|
.EXAMPLE
|
|
Get-ITDVMwareVMHostHBA -VMHost "esxi01.domain.local"
|
|
Retrieves HBA information from the specified ESXi host.
|
|
|
|
.EXAMPLE
|
|
Get-ITDVMwareVMHostHBA
|
|
Retrieves HBA information from all connected ESXi hosts.
|
|
#>
|
|
|
|
function Get-ITDVMwareVMHostHBA {
|
|
[CmdletBinding()]
|
|
param (
|
|
[string]
|
|
$VMHostName
|
|
)
|
|
|
|
begin {
|
|
|
|
}
|
|
|
|
process {
|
|
If ($PSBoundParameters.ContainsKey('VMHostName')) {
|
|
$AllVMHosts = Get-VMHost -Name $VMHostName
|
|
}
|
|
Else {
|
|
$AllVMHosts = Get-VMHost
|
|
}
|
|
|
|
ForEach ($VMHost in $AllVMHosts) {
|
|
$HBAs = $null
|
|
$HBAs = Get-VMHostHba -VMHost $VMHost -Type FibreChannel
|
|
ForEach ($HBA in $HBAs) {
|
|
$wwn = "{0:X}" -f $HBA.NodeWorldWideName
|
|
$wwp = "{0:X}" -f $HBA.PortWorldWideName
|
|
$obj = [PSCustomObject]@{
|
|
'VMHostName' = $VMHost.Name;
|
|
'Device' = $HBA.Device;
|
|
'Model' = $HBA.Model;
|
|
'Status' = $HBA.Status;
|
|
'NodeWorldWideName' = (0..7 | ForEach-Object { $wwn.Substring($_ * 2, 2) }) -join ':'
|
|
'PortWorldWideName' = (0..7 | ForEach-Object { $wwp.Substring($_ * 2, 2) }) -join ':'
|
|
}
|
|
Write-Output $obj
|
|
}
|
|
}
|
|
}
|
|
|
|
end {
|
|
|
|
}
|
|
} |