Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-09-04
2
Medium Priority
?
1,600 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Windows Server 2003 introduced persistent Volume Shadow Copies and made 2003 a must-do upgrade.  Since then, it's been a must-implement feature for all servers doing any kind of file sharing.
This tutorial will walk an individual through the process of installing of Data Protection Manager on a server running Windows Server 2012 R2, including the prerequisites. Microsoft .Net 3.5 is required. To install this feature, go to Server Manager…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

670 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