Is there a way to prevent/enable the following(by means of WMI/Powershell) by setting a flag on the
Hyper-V host? Would setting a Hyper-V host into ‘maintenance mode’ using SCVMM effectively do the
following?
1.Prevent the migration of guests from the host (in question) to another Hyper-V host
2.Prevent the migration of guests from another Hyper-V host to the host
 
Resolution :
 

Yes, you can use the powershell to achieve this.

you can use set-vmhost commandlet

ps c:\> $vmhost = get-vmhost -computername "mymachine.domain.com"

ps c:\> Set-VMHost -VMHost $vmhost -AvailableForPlacement $false

Maintenance modes are not supported for HyperV hosts

You can however mark a host ‘not available for placement’ to prevent VMs from being created/migrated into this host. To do this, right click on the host and goto properties. On the status tab, uncheck the checkbox which says ‘host is available for placement’

Advertisements