I need to enable cpu compatibility on all vms within a list.
The code needs to go to each node and find the vms in the list, but my script that has 2 foreach doesn't find the vm
How could I improve the script so that the execution goes to each Cluster Node and finds the VMs in the list?
My code
$Nodes = Get-ClusterNode
foreach ($item in $Nodes) {
$vms = Get-Content -Path "C:\scripts\vmscpu.txt"
foreach ($item in $vms) {
Stop-VM -Name $vms
Start-Sleep -s 8
Get-VMProcessor -VMName $vms | Set-VMProcessor -CompatibilityForMigrationEnabled $true
Start-VM -Name $vms
}
}