VMware Cloud Community
VijayKumarMyada
Enthusiast
Enthusiast
Jump to solution

Find shared datastore names in vcenter under different clusters

Am trying to list shared datastores in between the clusters in vcenter

Get-Datastore | where{$_.ExtensionData.Summary.MultipleHostAccess} | select Name, Datacenter, Cluster, Host |ft -AutoSize

It is not giving the host-name and cluster name in which Datastore is shared so we can restrict the datastore only to the required cluster.

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Sure, try like this

Get-Datastore -PipelineVariable ds |

where{$_.ExtensionData.Summary.MultipleHostAccess} |

ForEach-Object -Process {

    $_.ExtensionData.Host |

    where{$_.MountInfo.Mounted} |

    Select @{N='Datatsore';E={$ds.Name}},

        @{N='DSC';E={(Get-DatastoreCluster -Datastore $ds).Name}},

        @{N='Datacenter';E={$ds.Datacenter}},

        @{N='Cluster';E={(Get-Cluster -VMHost (Get-View -Id $_.Key -Property Name).Name).Name}},

        @{N='VMHost';E={(Get-View -Id $_.Key -Property Name).Name}}

}


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

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

You could do something like this

Get-Datastore -PipelineVariable ds |

where{$_.ExtensionData.Summary.MultipleHostAccess} |

ForEach-Object -Process {

    $_.ExtensionData.Host |

    where{$_.MountInfo.Mounted} |

    Select @{N='Datatsore';E={$ds.Name}},

        @{N='Datacenter';E={$ds.Datacenter}},

        @{N='Cluster';E={(Get-Cluster -VMHost (Get-View -Id $_.Key -Property Name).Name).Name}},

        @{N='VMHost';E={(Get-View -Id $_.Key -Property Name).Name}}

}


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

Reply
0 Kudos
VijayKumarMyada
Enthusiast
Enthusiast
Jump to solution

can i also add sDRS cluster name if datastores are part of sDRS.

Select @{N='Datatsore';E={$ds.ClusterName}},

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Sure, try like this

Get-Datastore -PipelineVariable ds |

where{$_.ExtensionData.Summary.MultipleHostAccess} |

ForEach-Object -Process {

    $_.ExtensionData.Host |

    where{$_.MountInfo.Mounted} |

    Select @{N='Datatsore';E={$ds.Name}},

        @{N='DSC';E={(Get-DatastoreCluster -Datastore $ds).Name}},

        @{N='Datacenter';E={$ds.Datacenter}},

        @{N='Cluster';E={(Get-Cluster -VMHost (Get-View -Id $_.Key -Property Name).Name).Name}},

        @{N='VMHost';E={(Get-View -Id $_.Key -Property Name).Name}}

}


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

Reply
0 Kudos