VMware Cloud Community
dekoshal
Hot Shot
Hot Shot
Jump to solution

VM with multple Datastore

Hi

Need help to  script to list vm with multiple datastore

VM Name      Cluster Name     Datastore name

VM1              Cluster 1              Datastore 1, Datastore 2, Datastore 3

vm2               Cluster 1              Datastore 2, Datastore 1

Best Regards,

Deepak Koshal

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-Cluster -PipelineVariable cluster |

Get-VM |

Select @{N='Cluster';E={$cluster.Name}},

    @{N='VM';E={$_.Name}},

    @{N='Datastore';E={(Get-View -Id $_.DatastoreIdList -property Name).Name -join '|'}}


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

View solution in original post

0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-Cluster -PipelineVariable cluster |

Get-VM |

Select @{N='Cluster';E={$cluster.Name}},

    @{N='VM';E={$_.Name}},

    @{N='Datastore';E={(Get-View -Id $_.DatastoreIdList -property Name).Name -join '|'}}


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

0 Kudos