Dear community
I need your help ,I have the below script that pulls out the report Checking for “Dead” paths on HBAs with PowerCLI . I was able to pull out the details but I have problem exporting them in to csv . when I export to csv the datastore property is showing like system.object . could some one please help me. Thanks.
Name : test.esx.com
Device : vmhba8
Cluster : testcluster.
ActiveP : 11
DeadP : 0
StandbyP : 11
Datastore : {DataStore_L1, DataStore_L2, DataStore_L3, DataStore_L4…}
$VMHosts = get-cluster | Get-VMHost | ? { $_.ConnectionState -eq “Connected” } | Sort-Object -Property Name
$allresults= @()
$datastore = @()
foreach ($VMHost in $VMHosts) {
write-host “Working on host $VMHost”
[ARRAY]$HBAs = $VMHost | Get-VMHostHba -Type “FibreChannel”
$datastore = Get-Datastore -VMHost $VMHost
foreach ($HBA in $HBAs) {
$results = “” | select Name, Device, Cluster, ActiveP, DeadP, StandbyP , Datastore
$pathState = $HBA | Get-ScsiLun | ? { $_.Vendor -match “EMC”} | Get-ScsiLunPath | Group-Object -Property state
$results.Name = $VMHost.Name
$results.Device = $HBA.Device
$results.Cluster = $VMHost.Parent
$results.ActiveP = [INT]($pathState | ? { $_.Name -eq “Active”}).Count
$results.DeadP = [INT]($pathState | ? { $_.Name -eq “Dead”}).Count
$results.StandbyP = [INT]($pathState | ? { $_.Name -eq “Standby”}).Count
$results.Datastore = [ARRAY]$datastore.name
$allresults += $results
}
}
# Display the results in Gridview
$allresults | ft -AutoSize
# Or export to a CSV
$allresults | export-csv -Path C:\Temp\path.csv
C:\Temp\path.csv
disconnect-viserver -confirm:$false