VMware Cloud Community
Greg86
Contributor
Contributor
Jump to solution

Get Datastore and DatastoreCluster information

I was trying to find out if it is possible using a PowerCLI cmd or Script to get a list of all datastores and which datastore cluster they belong too. 

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

No error, but it will not list the datastores that are not part of a datastorecluster.

If you want all datastores, you could do

Get-Datastore |

Select Name,@{N='DatastoreCluster';E={Get-DatastoreCluster -Datastore $_ | Select -ExpandProperty Name}}


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

View solution in original post

0 Kudos
7 Replies
LucD
Leadership
Leadership
Jump to solution

You could tackle this in reverse, something like

foreach($dsc in Get-DatastoreCluster){

  Get-Datastore -Location $dsc |

  Select Name,@{N='DatastoreCluster';E={$dsc.Name}}

}

This assumes all datastores belong to a datastorecluster


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

Greg86
Contributor
Contributor
Jump to solution

Thanks for the quick reply LucD! We have a few datastores that are not part of a cluster, will the script just return a null value? or would it error out?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

No error, but it will not list the datastores that are not part of a datastorecluster.

If you want all datastores, you could do

Get-Datastore |

Select Name,@{N='DatastoreCluster';E={Get-DatastoreCluster -Datastore $_ | Select -ExpandProperty Name}}


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

0 Kudos
Greg86
Contributor
Contributor
Jump to solution

This CMD ran but did not display any results in the datastorecluster column.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Which PowerCLI version are you running ?

Do a

Get-PowerCLIVersion


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

0 Kudos
Greg86
Contributor
Contributor
Jump to solution

PowerCLI 5.0

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That explains, the Get-DatastoreCluster cmdlet isn't available in that version.

Can you upgrade ?


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