Automation

 View Only
  • 1.  Add WWN WWP on SANLUN script

    Posted Dec 05, 2017 08:35 AM

    Hello,

    I have this script:

    $report = foreach($esx in (Get-VMHost | where{$_.PowerState -eq "PoweredOn"})){

        foreach($lun in (Get-ScsiLun -VmHost $esx -LunType disk)){

            Get-ScsiLunPath -ScsiLun $lun | `

            Select @{N="Host";E={$esx.Name}},

                @{N="LUN";E={$lun.CanonicalName}},

                @{N="Target";E={

                    "{0:x} {1:x}" -f ($_.Extensiondata.Transport.NodeworldwideName,

                                      $_.Extensiondata.Transport.PortworldwideName)

                }}

        }

    }

    $report | Export-Csv -path C:\Users\gemela\Desktop\SANLUN.csv

    Where I get, hostname, Lun and target, I would like to get this WWN and WWP in HEX format like this previous post:

    @{N='HBA Node WWN';E={$wwn = "{0:X}" -f $_.NodeWorldWideName; (0..7 | %{$wwn.Substring($_*2,2)}) -join ':'}},

            @{N='HBA Node WWP';E={$wwp = "{0:X}" -f $_.PortWorldWideName; (0..7 | %{$wwp.Substring($_*2,2)}) -join ':'}}

    Thanks



  • 2.  RE: Add WWN WWP on SANLUN script

    Posted Dec 05, 2017 09:10 AM

    You mean something like this?

    $report = foreach($esx in (Get-VMHost | where{$_.PowerState -eq "PoweredOn"})){ 

        foreach($lun in (Get-ScsiLun -VmHost $esx -LunType disk)){ 

            Get-ScsiLunPath -ScsiLun $lun |

            Select @{N="Host";E={$esx.Name}}, 

                @{N="LUN";E={$lun.CanonicalName}},

                @{N='WWN';E={$wwn = "{0:X}" -f $_.Extensiondata.Transport.NodeworldwideName; (0..7 | %{$wwn.Substring($_*2,2)}) -join ':'}},

                @{N='WWP';E={$wwn = "{0:X}" -f $_.Extensiondata.Transport.PortworldwideName; (0..7 | %{$wwn.Substring($_*2,2)}) -join ':'}}

        } 

     

    $report | Export-Csv -path C:\Users\gemela\Desktop\SANLUN.csv 



  • 3.  RE: Add WWN WWP on SANLUN script

    Posted Dec 05, 2017 09:57 AM

    Hi LucD,

    Script work but for some reason I get different WWN / WWP, I compare with other script and make also check in vcenter,

    With this I get correct data:

    $cluster = Get-Cluster

    $hosti = $cluster | Get-VMHost

    $report333 = foreach ($esxi in $hosti) {

        Get-VMHosthba -VMHost $esxi -type FibreChannel |

        Select  @{N="Host";E={$esxi.Name}},

            @{N='HBA Node WWN';E={$wwn = "{0:X}" -f $_.NodeWorldWideName; (0..7 | %{$wwn.Substring($_*2,2)}) -join ':'}},

            @{N='HBA Node WWP';E={$wwp = "{0:X}" -f $_.PortWorldWideName; (0..7 | %{$wwp.Substring($_*2,2)}) -join ':'}}

    }

    $report333 | Export-csv  -Path C:\Users\xxgemela\Desktop\WWNTECO.csv –NoTypeInformation



  • 4.  RE: Add WWN WWP on SANLUN script

    Posted Dec 05, 2017 10:31 AM

    Not sure what WWNs you are actually looking for, but when I check I get the values I see in the Web Client under Storage Adapters and Devices.

    Perhaps you could include a screenshot of what you want to see.



  • 5.  RE: Add WWN WWP on SANLUN script

    Posted Dec 05, 2017 10:40 AM

    I looking for WWN under Storage Adapters,

    I have an example for one host

    host10

     

    This is what is vcenter and in the script

    $report333 = foreach ($esxi in $hosti) {

        Get-VMHosthba -VMHost $esxi -type FibreChannel |

        Select  @{N="Host";E={$esxi.Name}},

            @{N='HBA Node WWN';E={$wwn = "{0:X}" -f $_.NodeWorldWideName; (0..7 | %{$wwn.Substring($_*2,2)}) -join ':'}},

            @{N='HBA Node WWP';E={$wwp = "{0:X}" -f $_.PortWorldWideName; (0..7 | %{$wwp.Substring($_*2,2)}) -join ':'}}

    }

    20:00:2C:44:FD:E1:47:6A

    20:00:2C:44:FD:E1:47:6B

    This is what I get with the main script:

    $report = foreach($esx in (Get-VMHost | where{$_.PowerState -eq "PoweredOn"})){

        foreach($lun in (Get-ScsiLun -VmHost $esx -LunType disk)){

            Get-ScsiLunPath -ScsiLun $lun | `

            Select @{N="Host";E={$esx.Name}},

                @{N="LUN";E={$lun.CanonicalName}},

                @{N='WWN';E={$wwn = "{0:X}" -f $_.Extensiondata.Transport.NodeworldwideName; (0..7 | %{$wwn.Substring($_*2,2)}) -join ':'}},

                @{N='WWP';E={$wwn = "{0:X}" -f $_.Extensiondata.Transport.PortworldwideName; (0..7 | %{$wwn.Substring($_*2,2)}) -join ':'}}

        }

    }

    50:06:0E:80:07:E6:B4:31

    50:06:0E:80:16:7B:FC:79



  • 6.  RE: Add WWN WWP on SANLUN script

    Posted Dec 05, 2017 11:07 AM

    Hi LucD,

    Sorry I check again in vSphere webclient , usually I check with app and I check only WWN under storage adapter, but now I see there is 'Target' in the paths,

    So information is correct, it point LUN devices.

    Thansk a lot



  • 7.  RE: Add WWN WWP on SANLUN script

    Posted Dec 05, 2017 11:10 AM