I think the active I/O failures are due to my using one of the "prod" HBAs for testing, and should not occur in a real usage of the script. Thanks again for your help!
Original Message:
Sent: Feb 03, 2025 01:04 PM
From: LucD
Subject: Disable paths on HBAs on multiple hosts?
The "busy" path might be a LUN that has active IO going to it.
It might be used in an RDM or have a Datastore on it.
The 1st ESXi node is due to the incorrect fields used in Write-Host line.
Try like this
$clusterName = 'MyCluster'# Target FC HBA Names, like "vmhba4"$TargetHBA = "vmhba2", 'vmhba4'# TargetPathState of all the LUNs/Paths from the specific HBA ("off" or "active" - case matters)$TargetState = "active"Get-Cluster -Name $clusterName | Get-VMHost -PipelineVariable esx | ForEach-Object -Process { $esxcli = Get-EsxCli -VMHost $esx -V2 $esxcli.storage.core.path.list.invoke() | where { $TargetHBA -Contains $_.Adapter -and $_.State -ne $TargetState } | ForEach-Object -Process { if ($esxcli.storage.core.path.set.invoke(@{state = $TargetState; path = $_.UID })) { Write-Host "$($esx.Name) $($_.Adapter) set to $TargetState Path=$($_.UID) " } } Get-VMHostStorage -VMHost $esx -RescanAllHba }
To see the changes you might have to do a rescan, I added a line at the end for that.
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Feb 03, 2025 12:25 PM
From: rblake
Subject: Disable paths on HBAs on multiple hosts?
So now it iterates through with occasional "busy" errors...but in VC, none of the paths actually change state. Also, it still only seems to be doing it for the first host in the cluster. (Also, appreciate everything you do. You are a great asset to the community!)
hostname.domain.org vmhba1 vmhba4 set to off Path=fc.20000025b5c10003:20000025b5c11a14-fc.524a937f85c20316:524a937f85c20316-naa.624a9370516b73ba4f5c4702000113f6
OperationStopped: H:\Scripts\vLabDisableHBAs.ps1:15:13
Line |
15 | if ($esxcli.storage.core.path.set.invoke(@{state = $TargetSta …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Message: EsxCLI.CLIFault.summary; InnerText: Unable to set path state. Error was: Unable to change path state, the path is marked as 'busy' by the VMkernel.:
| Busy: VSI node (1966:VSI_NODE_storage_scsifw_paths_state) EsxCLI.CLIFault.summary
hostname.domain.org vmhba1 vmhba4 set to off Path=fc.20000025b5c10003:20000025b5c11a14-fc.524a9372c5765b06:524a9372c5765b06-naa.624a9370c5bdc13626a4fa5a000113e8
hostname.domain.org vmhba1 vmhba4 set to off Path=fc.20000025b5c10003:20000025b5c11a14-fc.524a937f85c20304:524a937f85c20304-naa.624a9370516b73ba4f5c4702000113e8
Original Message:
Sent: Feb 03, 2025 11:54 AM
From: LucD
Subject: Disable paths on HBAs on multiple hosts?
My bad, I didn't notice that the variable $lunPath was not initialised.
It should have been the pipeline variable, like this
$clusterName = 'MyCluster'# Target FC HBA Names, like "vmhba4"$TargetHBA = "vmhba2", 'vmhba4'# TargetPathState of all the LUNs/Paths from the specific HBA ("off" or "active" - case matters)$TargetState = "active"Get-Cluster -Name $clusterName | Get-VMHost -PipelineVariable esx | ForEach-Object -Process { $esxcli = Get-EsxCli -VMHost $esx -V2 $esxcli.storage.core.path.list.invoke() | where { $TargetHBA -Contains $_.Adapter -and $_.State -ne $TargetState } | ForEach-Object -Process { if ($esxcli.storage.core.path.set.invoke(@{state = $TargetState; path = $_.UID })) { Write-Host "$TargetHost $TargetHBA set to $TargetState Path=$($_.UID) " } } }
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Feb 03, 2025 11:40 AM
From: rblake
Subject: Disable paths on HBAs on multiple hosts?
Thanks for the input - I'm getting weird errors though. It gives me a bunch of the first error, all with that same path name, and the second is also reporting the same path repeatedly set to off, but never turns it off. (I am not sure if showing both hbas in the second instance on the same line is an error or not.) I did intentionally switch the hbas from the original because it isn't all zoned yet, but I could use those without actually breaking all paths.
Also, to clarify, the second error message is only ever from the first host in the cluster and that same path.
PS H:\Scripts> . 'H:\Scripts\vLabDisableHBAs.ps1'
OperationStopped: H:\Scripts\vLabDisableHBAs.ps1:15:13
Line |
15 | if ($esxcli.storage.core.path.set.invoke(@{state = $TargetSta …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Message: EsxCLI.CLIFault.summary; InnerText: Unable to find a path with the name
| fc.20000025b5c10003:20000025b5c11a14-fc.524a937f85c20304:524a937f85c20304-naa.624a9370516b73ba4f5c4702000113e8EsxCLI.CLIFault.summary
(x36)
hostname.domain.org vmhba1 vmhba4 set to off Path=fc.20000025b5c10003:20000025b5c11a14-fc.524a937f85c20304:524a937f85c20304-naa.624a9370516b73ba4f5c4702000113e8
hostname.domain.org vmhba1 vmhba4 set to off Path=fc.20000025b5c10003:20000025b5c11a14-fc.524a937f85c20304:524a937f85c20304-naa.624a9370516b73ba4f5c4702000113e8
hostname.domain.org vmhba1 vmhba4 set to off Path=fc.20000025b5c10003:20000025b5c11a14-fc.524a937f85c20304:524a937f85c20304-naa.624a9370516b73ba4f5c4702000113e8
(x16)
PS H:\Scripts>
Original Message:
Sent: Feb 01, 2025 05:07 AM
From: LucD
Subject: Disable paths on HBAs on multiple hosts?
You could try something like this
$clusterName = 'MyCluster'# Target FC HBA Names, like "vmhba4"$TargetHBA = "vmhba2", 'vmhba4'# TargetPathState of all the LUNs/Paths from the specific HBA ("off" or "active" - case matters)$TargetState = "active"Get-Cluster -Name $clusterName | Get-VMHost -PipelineVariable esx | ForEach-Object -Process { $esxcli = Get-EsxCli -VMHost $esx -V2 $esxcli.storage.core.path.list.invoke() | where { $TargetHBA -Contains $_.Adapter -and $_.State -ne $TargetState } | ForEach-Object -Process { if ($esxcli.storage.core.path.set.invoke(@{state = $TargetState; path = $LunPath.UID })) { Write-Host "$TargetHost $TargetHBA set to $TargetState Path=$($LunPath.UID) " } } }
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Jan 31, 2025 03:41 PM
From: rblake
Subject: Disable paths on HBAs on multiple hosts?
I need to enable or disable a secondary set of HBAs in a cluster of 4 hosts. I found one that disables all paths for a given HBA on a given host. How do I modify that for 2 given HBAs (2 and 4) for each of the 4 hosts? Code I'm using is below. I'm sure it's simple, but I'm no coder and kind of backing into this. Thanks in advance!
# Target hostname
$TargetHost = "hostname.orgname"
# Target FC HBA Name, like "vmhba4"
$TargetHBA = "vmhba1"
# TargetPathState of all the LUNs/Paths from the specific HBA ("off" or "active" - case matters)
$TargetState = "active"
$esxcli = Get-VMHost -Name $TargetHost | Get-EsxCli -V2
$AllPaths = $esxcli.storage.core.path.list.invoke() | where {$_.Adapter -eq $TargetHBA} | Select-Object -Property Adapter, State, UID | where {$_.State -ne $TargetState}
ForEach ($LunPath in $AllPaths)
{
IF ($esxcli.storage.core.path.set.invoke(@{state=$TargetState;path=$LunPath.UID}))
{
Write-Host "$TargetHost $TargetHBA set to $TargetState Path=$($LunPath.UID) "
}
}