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 255.255.0.0 right back.
Any help would be appreciated. I have looked for a force type setting but have not found any.