Enthusiast
Enthusiast

Get-ScsiLunPath output different for ESXi 6 hosts

hi, I have been using this script flawlessly on my ESXi 5.5 hosts.:

http://www.vmspot.com/disable-esxi-fibre-ports-using-powercli/

However it just stopped working on my ESXi 6 host

i did some debugging and found that the output of Get-ScsiLunPath command is different on the new host.

$Scsipaths = $scsilun | Get-ScsiLunPath | Where-Object {$_.Name -Like "*$WWN*"}

The correct value should be like 5.5 host:

fc.xxxxxxxxxxxxxxxx:xxxxxxxxxxxxxxxx-fc.xxxxxxxxxxxxxxxx:xxxxxxxxxxxxxxxx-naa.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:Active

However it is getting:

vmhba65:C0:T0:L71:Active


Therefore the command is not able to parse the variable and results in failure:
 

Set-ScsiLunPath -ScsiLunPath $Scsipath -Active $false


Please help if anyone knows a solution to it. Thanks in advance.

0 Kudos
3 Replies
Enthusiast
Enthusiast

any help

0 Kudos
Enthusiast
Enthusiast

I imagine you're not still having the issue, but I've updated the VMSpot script to work on vSphere 6:

Switch Fabric Got Your VMs Down? – CloudHarbinger http://cloudharbinger.com/

It looks as if the LunPath attribute was deprecated.  Using the "Device" attribute of the HBA (get-VMHostHba) and comparing it to the "Name" attribute of the path (get-SCSILunPath) seems to work.  Full script at link above, but basically:

#Collect ESXi host name from command line

[cmdletbinding()]

Param([string]$VMhost)

#Load the Vmware Powershell Snapin (For users executing script from powershell)

Add-PSSnapin VMware.VimAutomation.Core -ErrorAction 'SilentlyContinue'

# Change "vcenter.fqdn" to targeted vCenter system

$vcenter = "vcenter.fqdn"

#Connect to vCenter

Write-Host ""

Write-Host "Connecting to vCenter..." -NoNewline

Connect-VIServer $vcenter | Out-Null

Write-Host " Connected"

Write-Host ""

#Get WWPN's from host

$WWNs = Get-VMHost $VMhost | Get-VMHostHba -Type FibreChannel | Select Device,VMHost,@{N="WWN";E={"{0:X}"-f$_.PortWorldWideName}},@{N="Status";E={$_.ExtensionData.Status}}

#Create a selection menu from WWPN's

Write-Host "WWPN's Available:"

$i = 0

foreach ($WWN in $WWNs)

{

$WWN_name = $WWN.Device

$WWN_WWN = $WWN.WWN

$WWN_host = $WWN.VMHost

$WWN_status = $WWN.Status

Write-Host "$i $WWN_name $WWN_WWN $WWN_host $WWN_status" -ForegroundColor 'Green'

$i ++

}

Write-Host ""

$Selection = Read-Host "Select a path to disable"

$WWN = $WWNs[$Selection].Device

#Validate that the user wants to disable ports

Write-Host ""

Write-Host "DISABLE $WWN " -ForegroundColor 'Red' -NoNewline

$validate = Read-Host "ARE YOU SURE? Y/N"

if ($validate -eq "Y")

{

#Get each disk device

$scsilun = Get-ScsiLun -VMHost $VMhost -LunType disk

#Get paths that use the selected WWPN

$scsipaths = $scsilun | Get-ScsiLunPath | Where-Object {$_.Name -Like "*$WWN*"}

# Disable / Enable each path using the selected WWPN

foreach ($scsipath in $scsipaths)

{

# Disables the paths. Comment out to re-enable

Set-ScsiLunPath -ScsiLunPath $Scsipath -Active $false

# To re-enable the paths, uncomment the following

# Set-ScsiLunPath -ScsiLunPath $Scsipath -Active $true

}

}

elseif ($validate -eq "N")

{

Write-Host ""

Write-Host "User Abort Process. Exiting" -ForegroundColor 'Red'

Write-Host ""

Exit

}

else

{

Write-Host ""

Write-Host "Invalid Entry. Exiting" -ForegroundColor 'Red'

Write-Host ""

Exit

}

0 Kudos
Enthusiast
Enthusiast

I don't know if i still have this issue or not as i moved to a different team. But i will check and get back. Thanks so much for you response.

0 Kudos