Using Hyper-V on 2012R2.
When using New-SCVirtualNetworkAdapte
r to create a NIC with an static IP address and using the -HardwareProfile option, I assume the IP address is automatically assigned from the static IP pool when the template using the hardware profile is deployed(seems like it, since that seems to work without me specifying an address). But when I am not assigning a new NIC to a hardware profile but to an existing VM that is turned off, it on the other hand does not seem to receive a static IP. The NIC shows up in VMM as for use with static IP, but no IP is assigned.
The code I am using goes like this:
$VMNetwork = Get-SCVMNetwork -VMMServer vmmServerFQDN -Name "VLAN 110 Network"
$VMSubnet = Get-SCVMSubnet -VMMServer vmmServerFQDN -Name "VLAN 110 Network_Subnet"
New-SCVirtualNetworkAdapter -VM "VMNameHere" -MACAddress "00:00:00:00:00:00" -MACAddressType Static -Synthetic -EnableVMNetworkOptimization $false -EnableMACAddressSpoofing $false -EnableGuestIPNetworkVirtualizationUpdates $false -IPv4AddressType Static -IPv6AddressType Dynamic -VMSubnet $VMSubnet -VMNetwork $VMNetwork