The Question
Set a static IP configuration with netsh:
netsh interface ipv4 set address name="Ethernet1" static 192.168.0.20 255.255.255.0 192.168.0.1
netsh interface ipv4 set dns name="Ethernet1" static 1.1.1.1 validate=no
netsh interface ipv4 add dns name="Ethernet1" addr=8.8.8.8 index=2 validate=no
Get the value of the Dhcp
property with Get-NetIPInterface
:
$Adapter = Get-NetAdapter 'Ethernet1'
($Adapter | Get-NetIPInterface -AddressFamily IPv4).Dhcp
I expect it to return Disabled
but it returns Enabled
.
Why does it return Enabled
?
Adapter Properties in Windows UI
After executing the netsh
commands as mentioned above Windows shows these settings for the Adapter:
They look like Dhcp
is disabled.
A way to get Get-NetIPInterface
to return Enabled
for the property Dhcp
When I follow these steps:
- Open the Adapter properties in Windows as shown above
- Press
OK
(without changing anything) - Close all dialogs
- Run
Get-NetIPInterface
as mentioned above again
Then for the property Dhcp
it returns Disabled
as expected.
I don't understand why, as I did not change anything.