VMware Cloud Community
AlbertWT
Virtuoso
Virtuoso
Jump to solution

PowerCLI script to list VM, VMDK size and Disk type per VMFS type ?

Hi All,

I've got the script by Alan R.: Get-Datastore | Select Name, @{N="NumVM";E={@($_ | Get-VM).Count}} | Sort Name

Can anyone here please assist me in modifying script above to list additional VM information like:

VM name, VMDK size and Disk type (Thin/Thick).

Thanks.

/* Please feel free to provide any comments or input you may have. */
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

How do you see the layout of the report, there are multiple VMs per datastore I assume?

I can place them all in one fields as one string.

Something like this

Get-Datastore |

Select Name,

    @{N="NumVM";E={$script:vms = $_ | Get-VM; $script:vms.Count}},

    @{N='VM';E={$script:vms.Name -join '|'}} |

Sort Name

Or you can go for one VM per line (this requires at least PS v4)

Get-Datastore -PipelineVariable ds | Get-VM |

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

    @{N="NumVMOnDatastore";E={$ds.ExtensionData.VM.Count}} |

Sort Name


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

How do you see the layout of the report, there are multiple VMs per datastore I assume?

I can place them all in one fields as one string.

Something like this

Get-Datastore |

Select Name,

    @{N="NumVM";E={$script:vms = $_ | Get-VM; $script:vms.Count}},

    @{N='VM';E={$script:vms.Name -join '|'}} |

Sort Name

Or you can go for one VM per line (this requires at least PS v4)

Get-Datastore -PipelineVariable ds | Get-VM |

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

    @{N="NumVMOnDatastore";E={$ds.ExtensionData.VM.Count}} |

Sort Name


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

AlbertWT
Virtuoso
Virtuoso
Jump to solution

Thanks for sharing such great script LucD , this one is more meaningful:

Get-Datastore | Select Name,

    @{N="NumVM";E={$script:vms = $_ | Get-VM; $script:vms.Count}},

    @{N='VM';E={$script:vms.Name -join '|'}} |

Sort Name

you are awesome and I learn something from the script above Smiley Happy.

/* Please feel free to provide any comments or input you may have. */
0 Kudos