Set static IPs on Hyper-V VMs / Windows Servers - Best way?

I set up a Windows Server testbed and asked a question here:
https://www.experts-exchange.com/questions/29143184/Hyper-V-VMs-physically-on-separate-subnets-howto.html
In the midst of the discussion, I tried to set a static IP address for each of the two VMs that I had implemented.
I used a method where I used Advanced Features of the VMs network adapter and assigned a MAC address.
Cliff Galiher took exception to what I did and I took that advice seriously.

Later, I tried to set things back to what I thought had been suggested but doing this broke the testbed.
So, the testbed remains with what I did....

I should point out that in the original testbed, each Server VM was on a different subnet and had a separate physical NIC.

Now I'm setting up another testbed with the real Servers and similar Hyper-V VMs.
I need to make sure that the VM Servers have static IP addresses - as before.
I don't want to overthink this or to overdo it.  
So, what is the recommended approach?
In this case, the 2 VMs in the Hyper-V platform will be in the same subnet and I envision one physical NIC for the pair.
So, in that sense, it's just a little simpler than the original testbed.
LVL 28
Fred MarshallPrincipalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Philip ElderTechnical Architect - HA/Compute/StorageCommented:
From the host in an elevated PowerShell console:
$VMName = "DC01"
Enter-PSSession -VMName $VMName -Credential $VMName\Administrator

# Set variables
$IPAddress = "192.168.88.252"
$Gateway = "192.168.88.1"
$DNS0 = "192.168.88.254"
$DNS1 = "192.168.88.252"

# Set Static IP Address for the VM
Set-NetIPInterface -InterfaceAlias Ethernet -DHCP Disabled
Remove-NetIPAddress -InterfaceAlias Ethernet -Confirm:$false
New-NetIPAddress -InterfaceAlias Ethernet -IPAddress $IPAddress –DefaultGateway $Gateway -PrefixLength 24
Set-DnsClientServerAddress -InterfaceAlias Ethernet -ServerAddresses $DNS0,$DNS1
IPConfig /RegisterDNS

Open in new window

That should do it.

I use VSCode for all of my PowerShell needs. This is a How-To get it all set up with a local Git repository.

PowerShell is simple, reliable, and repeatable thus consistent every time.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fred MarshallPrincipalAuthor Commented:
Philip Elder:  Thank you!  So, presumably one could do the same thing with the Windows GUI in the VM.
Either way, just as simple as that and what one really ought to expect!
Thanks
Philip ElderTechnical Architect - HA/Compute/StorageCommented:
The advantage of using the PowerShell Remote Session is the time saved as one need not log on to the virtual machine until such time as software needs to be installed and configured.

Virtually all Microsoft Roles & Features can be installed, configured, and managed in this manner from a Hyper-V host.
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

kevinhsiehCommented:
You can assign the IP address on the VM JUST LIKE A PHYSICAL MACHINE.

Don't over think this.
Fred MarshallPrincipalAuthor Commented:
kevinhsieh:  yep.  I have no idea what I was thinking months ago when I set up the testbed.  ...  Probably best forgotten.
Fred MarshallPrincipalAuthor Commented:
Thank you both!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.