dkvwcredit
Contributor
Contributor

Getting System.Object values in Get-Datastore

i'm getting "System.Object" values for DeviceID in this powercli statement when extracting to an excel sheet. i realize its because i'm some datastores have multiple deviceids. how would i show all values?

Get-Datastore | foreach { $_ | Add-Member NoteProperty “URL” $_.extensiondata.info.url -PassThru
| Add-Member NoteProperty “DeviceID” $_.extensiondata.info.vmfs.extent.diskname -PassThru }
| select -ExpandProperty Name,CapacityGB,FreeSpaceGB,DeviceID,URL
|Export-Excel -Path $file

0 Kudos
1 Reply
LucD
Leadership
Leadership

Can you try like this?
Note that a Datastore can have more than 1 Extent, hence the -join.

Get-Datastore |
Select Name,CapacityGB,FreeSpaceGB,
    @{N='URL';E={$_.ExtensionData.Info.Url}},
    @{N='DeviceId';E={$_.ExtensionData.Info.Vmfs.Extent.Diskname -join '|'}} |
Export-Excel -Path $file

 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos