Get-HBAInfo (SAN)

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche

-> This function/script is moved to GitHub!

Get-HBAInfo Function

function Get-HBAInfo {
   [CmdletBinding()]
   Param
   (
     [Parameter(Mandatory=$false, ValueFromPipeline=$true, Position=0)]
     $ComputerName
   )
 
   Begin {
      $Namespace = "root\WMI"
} Process {
     $port = Get-WmiObject -Class MSFC_FibrePortHBAAttributes -Namespace $Namespace @PSBoundParameters
     $hbas = Get-WmiObject -Class MSFC_FCAdapterHBAAttributes -Namespace $Namespace @PSBoundParameters
     $hbaProp = $hbas | Get-Member -MemberType Property, AliasProperty | Select -ExpandProperty name | ? {$_ -notlike "__*"}
     $hbas = $hbas | Select $hbaProp
     $hbas | %{ $_.NodeWWN = ((($_.NodeWWN) | % {"{0:x2}" -f $_}) -join ":").ToUpper() }
 
     ForEach($hba in $hbas) {
       Add-Member -MemberType NoteProperty -InputObject $hba -Name FabricName -Value (
        ($port |? { $_.instancename -eq $hba.instancename}).attributes | `
        Select `
        @{Name='Fabric Name';Expression={(($_.fabricname | % {"{0:x2}" -f $_}) -join ":").ToUpper()}}, `
        @{Name='Port WWN';Expression={(($_.PortWWN | % {"{0:x2}" -f $_}) -join ":").ToUpper()}} 
        ) -passThru
    }
  }
}


Show Number of HBA paths per LUN

(gwmi -Namespace root\wmi -Class mpio_disk_info).driveinfo | % {Write-host "Name: $($_.name) Paths: $($_.numberpaths)"}

or

(gwmi -Namespace root\wmi -Class mpio_disk_info).DriveInfo | Select @{N='DiskNumber';E={($_.Name -replace "(MPIO\sDisk)([0-9]*)" , '$2')}}, @{N='UniqueID';E={$_.SerialNumber}}, @{N='NumberOfPaths';E={$_.NumberPaths}}



Source: http://www.purepowershellguy.com/?p=54