Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 201333

Re: VM Allocation and Consumption Report

$
0
0

Try it like this

 

New-VIProperty-Name'FolderPath'-ObjectType'VirtualMachine'-Value {
 
param($vm)

 
$path=@()
 
$excludeFolders="Datacenters","vm"
 
$parent=$vm.ExtensionData
 
while($parent.Parent){
   
$parent=Get-View$parent.Parent
   
if($excludeFolders-notcontains$parent.Name){
     
$path+=$parent.Name
    }
  }
  [
string]::Join('/',$path[($path.Count-1)..0])
}
-Force-BasedOnExtensionProperty'Parent'|Out-Null

Get-VM|Group-ObjectFolderPath|%{
 
New-ObjectPSObject-Property@{
   
Consumer=$_.Name
   
"No. of Virtual Machines"=$_.Group.Count
   
"Allocated CPU"=$_.Group|Measure-Object-PropertyNumCPU-Sum|Select-ExpandPropertySum
   
"Allocated Memory"=$_.Group|Measure-Object-PropertyMemoryGB-Sum|Select-ExpandPropertySum
   
"Disk Provisioned"=$_.Group|Measure-Object-PropertyProvisionedSpaceGB-Sum|Select-ExpandPropertySum
  }
}

It uses a VIProperty to get the blue folderpath, and then groups the VM on this property.


Viewing all articles
Browse latest Browse all 201333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>