Creating a VM from virtual disk or existing virtual machine is a basic task in every VMM infrastructure. What if you want to assign IP from static pool instead of dynamic which is just the one option by default for such deployments? Well,doing this in wizard, will end by receiving a warning:“You cannot customize IP settings for a stored virtual machine or a virtual hard disk. You can only customize IP settings if you use a VM template” and static IP pool will be grayed out.

If you don’t want to create VM template for some reason, PowerShell will help you to fix this behavior. Just start VM creation wizard, edit hardware and other settings and leave Dynamic IP for network adapter. Then don’t run VM and execute the following PowerShell script:
#Get VM
$vm=Get-SCVirtualMachine -Name "rl-srv-01.demolab.com"
#Get static pool which you are going to use with that VM (here I'm filtering pool by address range)
$pool=Get-SCStaticIPAddressPool|? {$_.IPAddressRangeStart -eq "10.10.25.1"}
#Grant changes
Grant-SCIPAddress -GrantToObjectType "VirtualNetworkAdapter" -GrantToObjectID $vm.VirtualNetworkAdapters[0].ID -StaticIPAddressPool $pool
#Update network adapter settings
Set-SCVirtualNetworkAdapter -VirtualNetworkAdapter $vm.VirtualNetworkAdapters[0] -IPv4AddressType static
Go back to the VM settings and check changes that script has successfully made:

Like this:
Like Loading...