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?
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
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
It worked. Now what the heck is going on in this script, lol, specifically:
[Regex]::Escape
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