joaomanoelc avatar image
0 Votes"
joaomanoelc asked

enable compatibility for vms migration on hyper-v cluster

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers