Hi,
Can someone please assist on how to extract a particular device name (eg. a device path that contains "clone" string) from an iSCSI software storage adapter. Below is the script that I found in the internet that extracts the devise attached to the iSCSI HBA adapter but I am having a hard time creating the logic.
$esxImpl = Get-VMHost -Name
$storImpl = Get-VMHostStorage -VMHost $esxImpl
stor = get-view $storImpl.ID
Foreach($adapter in $stor.StorageDeviceInfo.ScsiTopology.Adapter){
foreach($target in $adapter.Target){
$nimblevolname = $target.Transport.IScsiName
Write-Host $nimblevolname
Write-Host $nimblevolname | where{$_.$nimblevolname -like "*clone"}
}
}
Thanks.
With a Where-clause you should be able to do it like this
$esxImpl = Get-VMHost -Name MyEsx
$storImpl = Get-VMHostStorage -VMHost $esxImpl
$stor = Get-View -Id $storImpl.ID
Foreach($adapter in $stor.StorageDeviceInfo.ScsiTopology.Adapter){
foreach($target in $adapter.target){
$target.Transport | where{$_.IscsiName -match "clone"} | Select IScsiName
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Isn't his giving you the required info ?
Get-VMHost -Name MyEsx |
Get-IScsiHbaTarget |
Select Name,Type,iSCSIHbaName,Address,Port
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
It will but I want to extract a particular device path which contains a particular string (eg. clone) from the device list. The main objective is to extract a specific device path which I will extract the alias or canonical name so that I can mount it on a VM as a VHD.
You can do that by inserting a Where-clause.
Which of the properties actually contains the string you want to filter upon?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The TARGET under the PATHS tab of the iSCSI Software Adapter details (see screenshot below)
I meant, is that string visible under any of the properties that are on the Select -Object cmdlet of the code I gave?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No it is not visible. The only (I think) way to get the device path name is by the script I mentioned at the beginning. It will have the same detail as the screenshot I sent previously.
Does this give you the desired entry?
$esxImpl = Get-VMHost -Name MyEsx
$storImpl = Get-VMHostStorage -VMHost $esxImpl
$stor = Get-View -Id $storImpl.ID
$stor.StorageDeviceInfo.HostBusAdapter | where{$_.IScsiName -like "*clone"}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Does not display anything. I manage to extract the particular device path name by using IF...
...
$nimblevolname = $target.Transport.IScsiName
if($nimblevolname -match "clone") {
Write-Host $nimblevolname
...
With a Where-clause you should be able to do it like this
$esxImpl = Get-VMHost -Name MyEsx
$storImpl = Get-VMHostStorage -VMHost $esxImpl
$stor = Get-View -Id $storImpl.ID
Foreach($adapter in $stor.StorageDeviceInfo.ScsiTopology.Adapter){
foreach($target in $adapter.target){
$target.Transport | where{$_.IscsiName -match "clone"} | Select IScsiName
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD. That is a more efficient code. Cheers!
Hi,
Im on a gun on this script. Now that I have extracted the particular device path, how can I know the alias or canonical name of the IscsiName that I have extracted? Thanks.