VMware Cloud Community
RajuVCP
Hot Shot
Hot Shot
Jump to solution

Script to get VM free space

Hi All,

I have a list of VMs which are thick provisioned, i am looking for the script which can give me free space for the given VMs.

I want to show the VMs list and get those VMs free space. something like get-content (my VM list)

Thanks in Advance.

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Not sure how your file looks, but if it is a file with just the names, you could do

Get-VM -Name (Get-Content -Path names.txt) | Get-VMGuest |

Select VmName,

    @{N='FreeSpaceGB';E={"{0:N1}" -f ($_.Disks | Measure-Object -Property FreeSpaceGB -Sum | select -ExpandProperty Sum)}}


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

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Something like this ?

Get-VM | Get-VMGuest |

Select VmName,

    @{N='FreeSpaceGB';E={"{0:N1}" -f ($_.Disks | Measure-Object -Property FreeSpaceGB -Sum | select -ExpandProperty Sum)}}


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

Reply
0 Kudos
RajuVCP
Hot Shot
Hot Shot
Jump to solution

Thanks LucD for reply.

I have list of VMs , need to get free space for those VMs only. something like i will save those VM names in csv or text.

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Not sure how your file looks, but if it is a file with just the names, you could do

Get-VM -Name (Get-Content -Path names.txt) | Get-VMGuest |

Select VmName,

    @{N='FreeSpaceGB';E={"{0:N1}" -f ($_.Disks | Measure-Object -Property FreeSpaceGB -Sum | select -ExpandProperty Sum)}}


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

Reply
0 Kudos
RajuVCP
Hot Shot
Hot Shot
Jump to solution

Thanks LucD,

This script was use full for me.

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
Reply
0 Kudos