VMware Cloud Community
paullee92
Enthusiast
Enthusiast
Jump to solution

Count resources

Hi Team,

I am running below command :

Get-Folder Test | Get-VM

I got output with Powerstate,Num Cpus and Memory

How to add condition to check if both of VM having same count of cpu and memory

I want a output to mention same count of cpu and memory and if not, need mention whether cpu is not match or memory

 

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You mean like this?

Get-Folder -Name Test | Get-VM |
Group-Object -Property NumCPu, MemoryGB |
ForEach-Object -Process {
  New-Object -TypeName PSObject -Property ([ordered]@{
      NumCPu =[int]($_.Name.Split(',')[0])
      MemoryGB = [int]($_.Name.Split(',')[1])
      Count = $_.Group.Count
      VM = $_.Group.Name -join '|'
    })
}


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

View solution in original post

Reply
0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

Your request is a bit confusing (for me at least).
What exactly do you want to see in the output?
Perhaps show a mockup?


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

Reply
0 Kudos
paullee92
Enthusiast
Enthusiast
Jump to solution

When running below command:

Get-Folder Test | Get-VM

I got output as per attached with CPU count and Memory size.

Screen shot attached.

I would like to add a Comparison, if the vm in the folder list having same cpu and memory size or not.

And extract it as a report, so i can know which folder having vm  resource mismatch

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I know what Get-VM produces as output, my question is about the "... extract it as a report"
What do you envisage seeing in such a report?


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

Reply
0 Kudos
paullee92
Enthusiast
Enthusiast
Jump to solution

To identify and count how many VM in the folder having different cpu and memory.

Later will assign all vm in the folder with same cpu and memory

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You mean like this?

Get-Folder -Name Test | Get-VM |
Group-Object -Property NumCPu, MemoryGB |
ForEach-Object -Process {
  New-Object -TypeName PSObject -Property ([ordered]@{
      NumCPu =[int]($_.Name.Split(',')[0])
      MemoryGB = [int]($_.Name.Split(',')[1])
      Count = $_.Group.Count
      VM = $_.Group.Name -join '|'
    })
}


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

Reply
0 Kudos