Solved

How to use New-SCVirtualNetworkAdapter cmdlet to set a static IP address

Posted on 2014-09-04
2
1,443 Views
Last Modified: 2014-09-05
Using Hyper-V on 2012R2.

When using New-SCVirtualNetworkAdapter 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

Open in new window

0
Comment
Question by:itnifl
2 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 40303702
Try with Set-SCVirtualNetworkAdapter
$Adapter = Get-SCVirtualNetworkAdapter -VM "VMNameHere"
Set-SCVirtualNetworkAdapter -IPv4AddressType Static -VirtualNetworkAdapter $Adapter -IPv4Addresses "IPv4Address here"

Open in new window


http://technet.microsoft.com/en-us/library/hh801488.aspx
0
 
LVL 2

Author Closing Comment

by:itnifl
ID: 40305500
Yes, works nice.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Resolve DNS query failed errors for Exchange
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question