Recently I migrated a VM from standalone Hyper-V server in 2016 to a Hyper-V cluster managed by Virtual Machine Manager (VMM) 2016. The VM was using DHCP for addressing and I wanted to flip it to get its address from the IP pool assigned to its logical network in VMM. However, even with the VM powered off, I found the setting to flip the VM to use a static IP was grayed out in the UI.
How to fix? PowerShell, via the VMM cmdlets. Here is a sample script, intended to run on your VMM server.
$vm = Get-ScvirtualMachine -Name “<My VM Name>" $staticIPPool = Get-SCStaticIPAddressPool -Name "< Name of my IP Pool>" Grant-SCIPAddress -GrantToObjectType "VirtualNetworkAdapter" -GrantToObjectID$vm.VirtualNetworkAdapters.ID -StaticIPAddressPool $staticIPPool Set-SCVirtualNetworkAdapter -VirtualNetworkAdapter $vm.VirtualNetworkAdapters-IPv4AddressType static <pre>
Questions or comments? Use the comments section below.