

To use this, you'll need to reference the current IP address and pipe it to New-NetIpAddress using the expected IP address, subnet mask prefix length, and default gateway. When going from DHCP to static, the PowerShell cmdlets treat this as a "new" IP address, thus the use of the New-NetIpAddresscmdlet. This sets the NIC to DHCP with no remnants of the previous default gateway. Yes Yes to All No No to All Suspend Help (default is "Y"): a Performing operation "Remove" on Target "NetRoute -DestinationPrefix 169.254.114.202/32 -InterfaceIndex 8 -NextHop 0.0.0.0 -Store Active"

PS> Get-NetIPAddress -InterfaceAlias 'Ethernet 2' | Remove-NetRouteĪre you sure you want to perform this action? We have to use a different command to remove this, called Remove-NetRoute. Upon further inspection though, the default gateway is grayed out in TCP/IP properties but still remains. Set-NetIPInterface -InterfaceAlias 'Ethernet 2' -Dhcp Enabled This will remove the IP address and subnet mask. To set this NIC to DHCP, we can use the Set-NetIpInterface command. Setting the current IP address in the GUI
