Windows 10 Disable or Enable Ethernet Adapter in Network Connections Dialog..

Well if that makes sense to you then you're a better man than me Charlie Brown.
I did finally find the powershell commands that will actually work and at least make some sense to me.
$netadapter = Get-NetAdapter -Name Ethernet
$netadapter | Set-NetIPInterface -Dhcp Disabled
$netadapter | New-NetIPAddress -IPAddress 192.168.1.222 -PrefixLength 24 –DefaultGateway 192.168.1.254
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses ("75.75.75.75","75.75.76.76")
Those separators that look kinda like backslashes are actual the "pipe" symbol. On my keyboard it's SHIFT + \

SOURCE: http://blogs.technet.com/b/askpfepl...hell-in-windows-8-or-windows-server-2012.aspx
 
The good news about this is the situation is temporary. The Microsoft person says it will be corrected by the RTM. If we have many more builds, hopefully it will be corrected prior to that. Good thing it doesn't really effect me right now.

I will have to do some testing. I don't yet understand how the placeholder pipes into the commands since the index is the only thing really used in the New-NetIPAddress. Something for me to do later today.. :)

 
I have been doing some testing and have noticed some things.

The New-NetIPAddress command will disable the DHCP.

The first time I ran the command, it seemed to remove the IPv4 DNS address. On subsequent attempts it did not.

I get an error message saying the Default Gateway is already present, so that part of the command may not be necessary, but I am not trying to change that address.

When you use -InterfaceAlias, will it always be Ethernet, or might there be another designation? What happens if you have two Ethernet adapters, such as on an ASUS X99-Deluxe motherboard. Would it not be advisable to use the Interface Index to make sure you have the correct adapter? I can't test this since I don't have the dual Ethernet Adapters on this board. But it would seem to be necessary to discern the designation, index or alias, of the targeted adapter.

Edit: I wanted to check what was being stored in $NetAdapter and got the following"

PS C:\WINDOWS\system32> write-host $netadapter
MSFT_NetAdapter (CreationClassName = "MSFT_NetAdapter",
DeviceID = "{99ADCA83-867F-4E4F-8A47-BBC626F20AB2}",
SystemCreationClassName = "CIM_NetworkPort",
SystemName = "ComputerName")
 
Last edited:
What happens if you have two Ethernet adapters
If you use the Get-NetAdapter command without any reference to a specific adapter it should display the names ("Alias") of all adapters present on the system.
Armed with that information then you should be able to perform other commands on a specific adapter based on its' name.
As shown on the link I posted above.
$netadapter = Get-NetAdapter -Name “Ethernet 2”
$netadapter | Set-NetIPInterface -Dhcp Disabled
$netadapter | New-NetIPAddress -IPAddress 10.0.0.1 -PrefixLength 8
 
Ok, you do not need the second command, it is accomplished by the last command.

If you already know the Alias or Index, you don't need to port ( | ) anything and you don't need to use $netadapter at all. It still appears, and I may not be outputting the contents of $netadapter correctly, that it does not contain either the Alias or Index of the adapters. The output of the command itself does.

The need for the DNS command is still in limbo. More testing might help decide the need for it.

I have been doing some reading on the net about Powershell also. I have been trying to pay strict attention to the date of the information. I have a book I will check and see if I can find any specific information about these commands. I need to learn about Porting, so I will probably see it in one of those sections.

I can use the two command lines, get-NetAdapter and new-NetIPAddress, and achieve the static IP address for the adapter. But following the procedure I am still seeing the Default Gateway address disappear, in some cases, so it looks some more trials to make certain which commands will get the job done.

Edit: I suppose I should really try it in Windows 10... ;)
 
More testing has revealed some more information. My problem with the Default Gateway is solved by disabling and enabling the Network Adapter, the Default Gateway address will return.

It also seems to be necessary to know what is wrong with a configuration before it can be repaired. If the DHCP server is not working or the network is being seen as Unknown, the situation will be different from someone who just wants to change their IP address.

If nothing else comes from this, I have gotten more experience with PowerShell and have a better understanding of how it works.
 
Back
Top