This short blog post is meant to show you how you can grab an IP address from a VMM IP pool for your virtual machines post deployments.
Recently, I found out that during specific DR scenarios with ASR (E2E), you have to use static IP addresses for some of your VMs, depending on the actual recovery plan you have created (but that is a different blog post).
In order to allocate an IP address from the VMM IP Pool, you can use the following lines of powershell:
$vm = Get-ScvirtualMachine -Name “NameOfVM"
$staticIPPool = Get-SCStaticIPAddressPool -Name "NameOfIPPool"
Grant-SCIPAddress -GrantToObjectType "VirtualNetworkAdapter" -GrantToObjectID $vm.VirtualNetworkAdapters.ID -StaticIPAddressPool $staticIPPool
Set-SCVirtualNetworkAdapter -VirtualNetworkAdapter $vm.VirtualNetworkAdapters -IPv4AddressType static
Check the job view in VMM to see which IP is allocated to the vNIC on the VM and ensure that these settings are reflected within the guest operating system as well.