VMware Cloud Community
dbutch1976
Hot Shot
Hot Shot
Jump to solution

Get all hosts of a certain processor type

I have one VMhost with a particular processor type. It is the sole host which has this particular processor in the cluster, which unfortunately is preventing vMotion. I'm going to power down the VMs and move them at some point, but in the meantime I would like to just try to find another host in the environment with the same processor type so I can vMotion the VMs to that one. I can use this command to get the processor type:

get-vmhost -name MYHOST.MYDOMAIN.COM | select Name,
@{N='ESXi CPU Type';E={$_.ProcessorType}}

This returns:
Name ESXi CPU Type
---- -------------
MYHOST.MYDOMAIN.COM AMD EPYC 7713 64-Core Processor

I now want to find any hosts in the environment running the same CPU, to do this I'm running this:

get-vmhost | Where-Object {$_.ProcessorType -in 'AMD EPYC 7713 64-Core Processor'} | select Name

However, this is returning no results at all, even the one that I know exists. What am I doing wrong?

 

 



1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Can you try with

Get-VMHost | 
Where-Object {$_.ProcessorType -match [Regex]::Escape('AMD EPYC 7713 64-Core Processor')} | 
select Name

 


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

View solution in original post

3 Replies
LucD
Leadership
Leadership
Jump to solution

Can you try with

Get-VMHost | 
Where-Object {$_.ProcessorType -match [Regex]::Escape('AMD EPYC 7713 64-Core Processor')} | 
select Name

 


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

dbutch1976
Hot Shot
Hot Shot
Jump to solution

It worked. Now what the heck is going on in this script, lol, specifically:

[Regex]::Escape

 

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The -match operator expects a RegEx on the right-hand side.
But since a ProcessorType value might contain some "special" RegEx characters (like [,],...) I escaped them by using this RegEx::Escape() function.


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