VMware Cloud Community
rxjoseph
Enthusiast
Enthusiast
Jump to solution

Get Datastore information

Hi LucD

I have put a simple script to collect all datastore information 

The script collecting the Datastore information is working ok however i need to get the Cluster names as well 

The issue i have here is I am getting all the cluster names in an array so its incorrect. How can i get the respective cluster name for the storage please 

 

Get-cluster |Get-Datastore |Select-Object ` @{N="Cluster" ;E={Get-cluster |select $($_name)}}, ` @{N="Datastore_Name"; E={$_.name}}, ` @{N="CapacityGB" ; E={[Math]::Round($_.CapacityGB)}},` @{N="FreeSpaceGB" ; E={[Math]::Round($_.FreeSpaceGB)}}, ` @{N="Freespace%" ; E={[Math]::Round($_.FreespaceGB/$_.CapacityGB *100) }}

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could use the PipelineVariable

Get-cluster -PipelineVariable cluster  |Get-Datastore |
Select-Object @{N="Cluster" ;E={$cluster.Name}},
    @{N="Datastore_Name"; E={$_.name}},
    @{N="CapacityGB" ; E={[Math]::Round($_.CapacityGB)}},
    @{N="FreeSpaceGB" ; E={[Math]::Round($_.FreeSpaceGB)}},
    @{N="Freespace%" ; E={[Math]::Round($_.FreespaceGB/$_.CapacityGB *100) }}


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

You could use the PipelineVariable

Get-cluster -PipelineVariable cluster  |Get-Datastore |
Select-Object @{N="Cluster" ;E={$cluster.Name}},
    @{N="Datastore_Name"; E={$_.name}},
    @{N="CapacityGB" ; E={[Math]::Round($_.CapacityGB)}},
    @{N="FreeSpaceGB" ; E={[Math]::Round($_.FreeSpaceGB)}},
    @{N="Freespace%" ; E={[Math]::Round($_.FreespaceGB/$_.CapacityGB *100) }}


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

rxjoseph
Enthusiast
Enthusiast
Jump to solution

Thank you LucD

The solution worked well

Appreciate your help

Many thanks

RXJ

Reply
0 Kudos