LucD,
Below is the output after I replacing
# Get SCSI LUNs
$version = [Version]$esxImpl.Version
if ($version.Major -ne 6 -and $version.Minor -ne 0)
{
$esxImpl | Get-ScsiLun -LunType disk | % {
$esxImpl.ExtensionData.config.Network.DnsConfig.Hostname + "-" + $_.CanonicalName.Split(".")[1]
}
}
Else
{
$esxImpl.ExtensionData.Config.StorageDevice.ScsiLun | Where-Object { $_.LunType -eq 'disk' } | % {
$esxImpl.ExtensionData.config.Network.DnsConfig.Hostname + "-" + $_.DiskName.Split(".")[1]
}
}
PS D:\> .\mytest1.ps1
You cannot call a method on a null-valued expression.
At D:\mytest1.ps1:17 char:4
+ $esxImpl.ExtensionData.config.Network.DnsConfig.Hostname + "-" + $_.DiskName. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At D:\mytest1.ps1:17 char:4
+ $esxImpl.ExtensionData.config.Network.DnsConfig.Hostname + "-" + $_.DiskName. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
and if I execute the below code
$clus = "IS"
Get-Cluster $clus | Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
$esx.ExtensionData.Config.StorageDevice.ScsiLun |
Where-Object { $_.LunType -eq 'disk' } | % {
$_ | Select @{N = 'Version'; E = { $esx.Version}}, DiskName, CanonicalName
}
}
I am getting the output but DiskName shows blank
Version DiskName CanonicalName
------- -------- -------------
6.5.0 naa.624a9370c377
6.5.0 naa.6006016001d0
6.5.0 naa.6006016001d0
6.5.0 naa.6006016001d0