TCPIP setting not stincking

Server 2012R2 in VMware 5.5 using the script below the settings don’t stick
$NIC = get-netadapter –name ethernet0
$NIC | set-netipinterface –dhcp disabled
$staticIP = Read-Host “What is the static IP for this NIC?”
$gateway = “gatewayIP”
$NIC |new-netipaddress –addressfamily IPv4 –ipaddress $staticIP`
–prefixlength 25 –type unicast –defaultgateway $gateway
$dns = “DNSserver1IP”,“DNSserver2IP”
set-dnsclientserveraddress –interfacealias ethernet0 –serveraddresses $DNS

Whether I reboot the server after the script or use restart-netadapter the settings do not stick. I get the I get the autoconfig IP 169.254.x.x with a subnet of right back.

Any help would be appreciated. I have looked for a force type setting but have not found any.

Hi Ken, you’re using a CIDR of 25, are you intentionally subclassing?

Also, are you checking the settings after setting them, to make sure they took effect prior to rebooting? As in, is the machine able to communicate with the network once you’ve finished the settings?

Have you confirmed there’s nothing in place in vSphere or Windows that might be forcing the setting back to DHCP?

Tim, Yes we are intentionally subclassing. We do not control the network, so we were give that portion of the class C subnet.

Don, I have tried with some mixed results. I am waiting on a fresh pair of VM’s to test on. As far as I know there is nothing in Vsphere that would set them back. We have a few VM’s in the environment that had the networking manually setup. I am trying to automate that process.

Personally, I’ve never had a problem using the cmdlets to set stuff, although nowadays I’m relying more on DSC.

OK still stuck. I am going to go check out the Vsphere side of this equation. But I thought I would throw some more info at you incase it jogs a memory.

When I manually put in the TCPIP setting shown. It works fine and I see it get identified a a private network. I can then see everything I want to see.

When I use the script it goes to “Unidentified” and I can’t see any portion of the network. I even tried using a full class subnetmask of

Any thoughts appreciated.

But after you use the script, you can run ipconfig and see the new settings?