As mentioned in my previous post about configuring Windows Server 2012 Core, you have multiple options. One is sconfig, but the preferred method is using PowerShell. PowerShell is a really powerful scripting language and Microsoft is pushing the use in all of their products.
In this post, I will describe how to configure your Windows Server 2012 Core installation using PowerShell. I will describe how to change your computername, set the IP address and join your server to the domain.
PowerShell
After you installed Windows Server 2012, log in to you server. Once logged in, the default shell is CMD. Just start powershell by typing “powershell” and press enter.
First thing I always do, is changing the computer name. The PowerShell command for this is:
Rename-Computer -NewName MYNAME
Now the computer name is changed, let’s change the IP address. We will need a few commands for this, since we need to know on which network adapter we need to change the IP address. First, use the following command:
Get-NetAdapter
This will output a list of available network adapters with their name, description, index and status.
As can be seen in this screenshot, the name of this adapter is “Ethernet”. We will need this name in the next command. To change the IP address on that specific network adapter, use the following command:
New-NetIPAddress -InterfaceAlias Ethernet -IPAddress 10.1.1.2 -DefaultGateway 10.1.1.1 -PrefixLength 24
Most of these values are pretty describing; ip address, gateway and interface name. The subnet mask is set by setting the PrefixLength option. A prefix length of 24 equals 255.255.255.0.
Now that the IP address is set, we will need to set the DNS server address. The is done by using the following command:
Set-DnsClientServerAddress -InterfaceAlias Ethernet -ServerAddress 10.1.1.1
Note that the “Ethernet” network adapter was used in this command. (found by using the Get-NetAdapter)
Disabling IPv6
Since I’m not using IPv6, I always disable the option in the network adapter configuration. This can be done using PowerShell by using a few commands. First we need to know what the component name is:
Get-NetAdapterBinding -InterfaceAlias Ethernet | Select-Object Name,DisplayName,ComponentID
Note that I’m only displaying some of the properties. The most important one is the ComponentID, since that property is needed in the next command.
As we can see in the list, the component id is “ms_tcpip6”. Now to disable this for the “Ethernet” network adapter (again, found using the Get-NetAdapter command). Use the following command:
Disable-NetAdapterBinding -InterfaceAlias Ethernet -ComponentID ms_tcpip6
Joining the domain
Now all IP configuration is done, let’s reboot the server by using this command:
shutdown /r /t 0
After the server rebooted, log in using your administrator credentials and start powershell again. Now to join the domain, just use this command:
Add-Computer -DomainName domain.local -DomainCredential (Get-Credential)
This will prompt you for domain credentials, just enter the correct credentials and press “OK”.
Again, reboot the server using this command:
shutdown /r /t 0
And that’s it! You’ve configured your machine to be domain joined and IP configured. Hope this post was helpful for you! Feel free to leave a comment or contact me if you have any questions.
shutdown /r /t 0 could be substituted with “Restart-Computer” instant reboot without any prompting
Warning, disabling IPv6 in server core breaks network configuration in sconfig…
Great blog! It helped me to get IPv6 deactivated on a Server 2012 R2 Core installation without messing around with the registry.
Great article! I’m now using these commands in one single ps1 file that is run after 2012R2 is installed. For intermediate reboots I used this mechanism:
http://www.codeproject.com/Articles/223002/Reboot-and-Resume-PowerShell-Script