Configuring Windows Server 2012 Core: PowerShell

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.

002-StartPoSh

First thing I always do, is changing the computer name. The PowerShell command for this is:

Rename-Computer -NewName MYNAME

003-RenameNow 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.

004-GetAdaptersAs 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.

005-SetIPNow 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)

006-SetDNSDisabling 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.

007-GetBindingAs 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

008-RemoveIPv6

Joining the domain

Now all IP configuration is done, let’s reboot the server by using this command:

shutdown /r /t 0

010-RebootAfter 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”.

012-DomainJoinAgain, 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.

 

 

 

 

 

 

 

4 thoughts to “Configuring Windows Server 2012 Core: PowerShell”

  1. shutdown /r /t 0 could be substituted with “Restart-Computer” instant reboot without any prompting

Leave a Reply

Your email address will not be published. Required fields are marked *

Complete the following sum: * Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.