Hello,
I'm trying to get this line to display with a Heading of Datastore Name and not just the datastore name.
Get-Datastore | Select Name,@{N="TotalSpaceGB";E={[Math]::Round(($_.ExtensionData.Summary.Capacity)/1GB,0)}}
Current Name
Name
----------------------
Datastore-01
Needed Name
Datastore Name
------------------------
Datastore-01
I have tried several things, but this might not be possible.
Get-Datastore | Select Name, {N="Datastore Name"};E={Name},@{N="TotalSpaceGB";E={[Math]::Round(($_.ExtensionData.Summary.Capacity)/1GB,0)}}
Thanks,
You're very close!
Get-Datastore | Select Name, {N="Datastore Name"};E={$_.Name},@{N="TotalSpaceGB";E={[Math]::Round(($_.ExtensionData.Summary.Capacity)/1GB,0)}}
I'm still not getting the Datastore Column to display my custom header, even with this change.
Get-Datastore | Select Name,{N="DataStore"};E={$_.Name},@{N="TotalSpaceGB";E={[Math]::Round(($_.ExtensionData.Summary.Capacity)/1GB,0)}}
Name N="DataStore"
-------------- ------------------------------
host1_Local
host2_Local
host3_Local
iSCSI1
iSCSI2
It is not even getting the data for N=
Name TotalSpaceGB
---- ------------
host1_Local 1
host2_Local 1
host3_Local 1
iSCSI1 30
iSCSI2 10
Thanks,
Try like this
Get-Datastore | Select Name, @{N="Datastore Name";E={$_.Name}},
@{N="TotalSpaceGB";E={[Math]::Round(($_.ExtensionData.Summary.Capacity)/1GB,0)}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Very Nice, it works with that change.
But do have one other question, is there anyway to not have the first section contained in the output.
Name Datastore Name TotalSpaceGB
---- -------------- ------------
host1_Local host1_Local 1
host2_Local host2_Local 1
host3_Local host3_Local 1
iSCSI1 iSCSI1 30
iSCSI2 iSCSI2 10
I'd like just Datastore Name and TotalSpaceGB, and not Name, which is a duplicate of the Datastore Name.
Thanks for the help and as always I learn something new,
I figured it out.
Get-Datastore | Select @{N="Datastore Name";E={$_.Name}},@{N="TotalSpaceGB";E={[Math]::Round(($_.ExtensionData.Summary.Capacity)/1GB,0)}}
Just removed the Name, and left just Select
Take Care,