vmwarelicense12
Enthusiast
Enthusiast

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

Jump to solution

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

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

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

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

0 Kudos
LucD
Leadership
Leadership

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


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

0 Kudos
vmwarelicense12
Enthusiast
Enthusiast

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

0 Kudos
LucD
Leadership
Leadership

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

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