Hi Luc,
I had a working script from one of your previous discussion Display active paths per datastore per host. It seems to have broken for some reason and is throwing the following error:
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
At C:\Scripts\Get_active_paths.ps1:7 char:16
+ $hss = Get-View <<<< $esx.Extensiondata.ConfigManager.StorageSystem
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
At C:\Scripts\Get_active_paths.ps1:7 char:16
+ $hss = Get-View <<<< $esx.Extensiondata.ConfigManager.StorageSystem
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
The script is intact and I have just customized the following:
connect-VIServer -Server $server
$Report = @()
$outputfile = "C:\ActivePaths_DCName.csv"
$esxhosts = Get-VMHost | select Name
foreach($esx in (Get-datacenter -name DCName | Get-VMHost))
{
$hss = Get-View $esx.Extensiondata.ConfigManager.StorageSystem
$lunTab = @{}
$hss.StorageDeviceInfo.ScsiLun | %{ $lunTab.Add($_.Key,$_.CanonicalName)
}
$pathTab = @{}
$hss.StorageDeviceInfo.MultipathInfo.Lun | %{
$pathState = @($_.Path | Group-Object -Property PathState | where {$_.Name -eq "active"} | Select -ExpandProperty Group)
if($pathTab.ContainsKey($_.Lun))
{
$pathTab[$_.Lun] += $pathState.Count
}
else
{
$pathTab.Add($lunTab[$_.Lun],$pathState.Count)
}
}
foreach($mount in ($hss.FileSystemVolumeInfo.MountInfo | where {$_.Volume.Type -eq "VMFS"}))
{
$record = $mount.Volume.Extent |
Select @{N="VMHost";E={$esx.Name}},
@{N="Datastore";E={$mount.Volume.Name}},
@{N="LUN";E={$_.DiskName}},
@{N="Active Paths";E={$pathTab[$_.DiskName]}}
}
}
if ($record)
{
$Report += $record
}
$Report | export-csv -path $outputfile -useculture -noclobber
Disconnect-VIServer -Server * -Confirm:$false
And there is an output file with only one host. Any help is appreciated.
Thx