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
Questions or comments? Use the comments section below.
Best practices for server configuration generally suggest installing applications / app data to a separate disk and volume than the OS. However, when you deploy a Windows 2008 or 2012 VM from a VM template in System Center 2012 R2 Virtual Machine Manager (VMM), you may find the second disk (vhd or vhdx) containing the application partition in an offline or uninitialized state when the VM is deployed from the template. The error you will see is “the disk is offline because of policy set by an administrator”.
Root Cause and Fix
This issue is caused by the default SAN Policy setting in Windows 2008 and Windows 2012. SAN policy was introduced in Windows Server 2008 to protect shared disks being accessed by multiple servers. If (and only if) the disk is not shared amongst other servers, you can change the SAN Policy setting to OnlineAll setting to get around this.
Perform these steps before running sysprep to create the VM template for VMM will ensure all the disks in a multi-disk VM template are in an online state on first boot.
To verify the current SAN Policy setting
From a command prompt, type DISKPART.EXE and then press Enter.
DISKPART> san and then press Enter.
If the default is in place, this command will return a status of “Offline Shared”
To change SAN Policy to OnlineAll, type the following at the DISPART prompt:
san policy=OnlineAll and then press Enter.
Now you can sysprep your VM to make your template with the assurance that non-OS disks in your template will be online on first boot.