VMware Cloud Community
vmwarelicense12
Enthusiast
Enthusiast
Jump to solution

Get vm´s from vm list and sum all used space

I need a script the can read a .txt file of vm names, and sum all vm disk to one number.

Can anyone help me in that?

$vmList = Get-Content c:\temp\vmlist.txt

???

0 Kudos
1 Solution

Accepted Solutions
vmwarelicense12
Enthusiast
Enthusiast
Jump to solution

Thanks all, for guiding me in the right direction.

I got i right after some tries.

This was what I was looking fore;)

$vmNames = Get-Content -Path C:\Temp\vm.txt

Get-VM -Name $vmNames | Measure-Object -Property UsedSpaceGB -Sum

__________________________________________________________________________

Was it helpful? Let us know by completing this short survey here

.

View solution in original post

0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

Something like this?

$vmNames = Get-Content -Path C:\Temp\vmlist.txt

Get-VM -Name $vmNames |

Select Name,UsedSpaceGB,ProvisionedSPaceGB


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

0 Kudos
vmwarelicense12
Enthusiast
Enthusiast
Jump to solution

I need all disks do be summed up to one number;)

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That is what those 2 numbers represent, capacity and used.


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

0 Kudos
vmwarelicense12
Enthusiast
Enthusiast
Jump to solution

You are right. What I want is to sum all disk usage of all the vm´s.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You could also do like this

$vmNames = Get-Content -Path .\vmnames.txt

Get-VM -Name $vmNames |

Select Name,

   @{N='HDSpaceGB';E={(Get-HardDisk -VM $_ | Measure-Object -Property CapacityGB -Sum).Sum}}


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

0 Kudos
vmwarelicense12
Enthusiast
Enthusiast
Jump to solution

Thanks all, for guiding me in the right direction.

I got i right after some tries.

This was what I was looking fore;)

$vmNames = Get-Content -Path C:\Temp\vm.txt

Get-VM -Name $vmNames | Measure-Object -Property UsedSpaceGB -Sum

__________________________________________________________________________

Was it helpful? Let us know by completing this short survey here

.

0 Kudos