In this article, I tried to describe basic cmd and PowerShell commands used to configure and manage Windows Server Core. I think this guide will be useful both for beginners and experienced system administrators as a reference to basic Server Core administration commands.
Windows Server Core advantages:
- Lower resource requirements;
- Improved stability and security; fewer updates are required (due to less amount of code and used components);
- Ideally suits for use as an infrastructure role server (Active Directory domain controller, DHCP server, Hyper-V host, SMB file server, etc.).
Server Core is licensed as a common physical or virtual Windows Server instance (unlike Hyper-V Server which is totally free).
To install Windows Server 2016/2019 in the Core mode, you must select a typical installation. If you select Windows Server (Desktop Experience), the GUI version of the operating system will be installed (in previous Windows Server versions it was called a Server with a GUI).
After Windows Server Core installation, you will be prompted to set a local administrator password.
When you log on to Server Core, the command prompt appears (cmd.exe). If you want the PowerShell console to be run instead of it, make some changes to the registry. Run the commands below:
Powershell.exe
Set-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion\WinLogon' -Name Shell -Value 'PowerShell.exe'
And restart your server:
Restart-Computer -Force
Ctrl+Alt+Delete
, open the Task Manager -> File -> Run -> and run cmd.exe
(or PowerShell.exe
).Configure Windows Server Core Using SCONFIG
You can use the built-in sconfig script for basic Server Core configuration. Just run the sconfig
command in your console. You will see a menu with several items:
Using the Server Configuration menu, you can do the following:
- Add a computer to a domain or a workgroup
- Change a computer name (hostname)
- Add a local administrator
- Allow/deny remote management and ICMP response
- Configure Windows Update settings
- Install Windows updates
- Enable/disable RDP
- Configure network adapter settings (IP address, gateway, DNS server)
- Set date and time
- Change telemetry settings
- Activate your Windows Server instance
- Log off, restart, or shut down your server
Each item in sconfig
has its number. To open the item you want, just type its number
and press Enter
.
Some sconfig menu items have subitems. To get to a setting, you also need to enter its number.
We will not describe all sconfig settings, since they are easy to understand. However, in most cases, administrators prefer using various PowerShell scripts to configure new hosts running Server Core. It is easier and faster, especially in mass deployment scenarios.
Basic PowerShell Commands to Configure Server Core
Let’s take a look at the basic PowerShell commands that can be used to configure Server Core.
To get information about your Windows Server build and PowerShell version:
Get-ComputerInfo | select WindowsProductName, WindowsVersion, OsHardwareAbstractionLayer
$PSVersionTable
To restart Server Core, run this PowerShell command:
Restart-Computer
To log off your Server Core console, use the command below:
logoff
Configure Network Settings on the Server Core with PowerShell
Now you need to configure network settings using PowerShell (by default, Windows is configured to receive an IP address from DHCP). Display a list of network adapters:
Get-NetIPConfiguration
Specify an index of your network adapter interface (InterfaceIndex
) you want to change and set a new IP address and DNS servers:
New-NetIPaddress -InterfaceIndex 4 -IPAddress 192.168.1.100 -PrefixLength 24 -DefaultGateway 192.168.1.1
Set-DNSClientServerAddress –InterfaceIndex 4 -ServerAddresses 192.168.1.11,192.168.101.11
Check the current network settings:
Get-NetIPConfiguration
Set-DnsClientServerAddress –InterfaceIndex 4 –ResetServerAddresses
Set-NetIPInterface –InterfaceIndex 4 -Dhcp Enabled
To enable/disable a network adapter:
Disable-NetAdapter -Name “Ethernet0”
Enable-NetAdapter -Name “Ethernet 0”
To enable, disable, or check the status of IPv6 support for your network adapter:
Disable-NetAdapterBinding -Name "Ethernet0" -ComponentID ms_tcpip6
Enable-NetAdapterBinding -Name "Ethernet0" -ComponentID ms_tcpip6
Get-NetAdapterBinding -ComponentID ms_tcpip6
To configure winhttp proxy server for PowerShell or system connections:
netsh Winhttp set proxy <servername>:<port number>
How to Set Date/Time?
You can set a date, time, or time zone using a graphical tool intl.cpl
or PowerShell:
Set-Date -Date "07/21/2021 09:00"
Set-TimeZone "Central Europe Standard Time”
Set Computer Name, Join Domain, and Activate Server Core
To change a computer name (hostname):
Rename-Computer -NewName be-srv01 -PassThru
To add a server to your on-premises Active Directory domain:
Add-Computer -DomainName "corp.woshub.com" -Restart
If you want to add additional users to the local administrators’ group, you can configure a Group Policy or add them manually:
Add-LocalGroupMember -Group "Administrators" -Member "corp\jsmith"
To activate Windows Server, enter your product key:
slmgr.vbs –ipk <productkey>
slmgr.vbs –ato
Or you may activate your host on a KMS server. For example, to activate Windows Server Core 2019 Standart on a KMS host:
slmgr /ipk N69G4-B89J2-4G8F4-WWYCC-J464C
slmgr /skms kms.corp.woshub.com:1688
slmgr /ato
Enabling Remote Administration of Windows Server Core
To allow remote access to Server Core via RDP:
cscript C:\Windows\System32\Scregedit.wsf /ar 0
To allow remote management:
Configure-SMRemoting.exe –Enable
Enable-NetFirewallRule -DisplayGroup “Windows Remote Management”
Configure-SMRemoting.exe -Get
To allow Win-RM for PowerShell Remoting:
Enable-PSRemoting –force
Configuring Windows Firewall on Server Core
You can find information about how to configure Windows Defender Firewall with PowerShell in this article. I will just show some basic commands here.
To enable Windows Defender Firewall for all profiles:
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
To change your network type from Public to Private:
Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private
To completely disable Windows Firewall (not recommended):
Get-NetFirewallProfile | Set-NetFirewallProfile -enabled false
To allow connection using remote management tools:
Enable-NetFireWallRule -DisplayName “Windows Management Instrumentation (DCOM-In)”
Enable-NetFireWallRule -DisplayGroup “Remote Event Log Management”
Enable-NetFireWallRule -DisplayGroup “Remote Service Management”
Enable-NetFireWallRule -DisplayGroup “Remote Volume Management”
Enable-NetFireWallRule -DisplayGroup “Remote Scheduled Tasks Management”
Enable-NetFireWallRule -DisplayGroup “Windows Firewall Remote Management”
Enable-NetFirewallRule -DisplayGroup "Remote Administration"
How to Install Updates on Windows Server Core
To manage update options, it is better to use Windows Update Group Policies. However, you can set the update settings manually.
To disable automatic updates:
Set-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU -Name AUOptions -Value 1
To automatically download available updates:
Set-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU -Name AUOptions -Value 3
To get the list of installed updates:
Get-Hotfix
Or
wmic qfe list
To install Windows updates manually, you can use the wusa
tool:
wusa kbnamexxxxx.msu /quiet
To install and manage updates from the command prompt, it is convenient to use the PSWindowsUpdate module for PowerShell.
Managing Windows Core Roles, Services, and Processes
To get a list of all available roles on Windows Server Core, run the following PowerShell command:
Get-WindowsFeature
To get a list of all installed roles and features in Windows Server (thus you can quickly understand what the server is used for):
Get-WindowsFeature | Where-Object {$_. installstate -eq "installed"} | ft Name,Installstate
For example, to install the DNS role, run this command:
Install-WindowsFeature DNS -IncludeManagementTools
To get a list of all services in Windows:
Get-Service
To see all stopped services:
Get-Service | Where-Object {$_.status -eq “stopped”}
To restart a service:
Restart-Service -Name spooler
To manage processes, you can use the Task Manager (taskmgr.exe) or the PowerShell:
Get-Process cmd, wuaucl* | Select-Object ProcessName, StartTime, MainWindowTitle, Path, Company|ft
Useful Windows Server Core Commands
Finally, I will show some useful PowerShell commands and scripts I often use to manage Server Core.
Information about the status and health of physical disks (the default Storage disk management module is used):
Get-PhysicalDisk | Sort Size | FT FriendlyName, Size, MediaType, SpindleSpeed, HealthStatus, OperationalStatus -AutoSize
Get-WmiObject -Class Win32_LogicalDisk |
Select-Object -Property DeviceID, VolumeName, @{Label='FreeSpace (Gb)'; expression={($_.FreeSpace/1GB).ToString('F2')}},
@{Label='Total (Gb)'; expression={($_.Size/1GB).ToString('F2')}},
@{label='FreePercent'; expression={[Math]::Round(($_.freespace / $_.size) * 100, 2)}}|ft
Information about the last 10 reboots of your server:
Get-EventLog system | where-object {$_.eventid -eq 6006} | select -last 10
A list of installed programs:
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize
To download and extract a ZIP file from an external website:
Invoke-WebRequest https://servername/file.zip -outfile file.zip
Expand-Archive -path '.\file.zip' -DestinationPath C:\Users\Administrator\Documents\
To copy all files from a directory to a remote computer over the network, you can use the Copy-Item cmdlet:
$session = New-PSSession -ComputerName be-dc01
Copy-Item -Path "C:\Logs\*" -ToSession $session -Destination "C:\Logs\" -Recurse -Force
To install the device driver:
Pnputil –i –a c:\install\hpspp\hpdp.inf
Microsoft also offers a special package, Server Core App Compatibility Feature on Demand (FOD), which allows you to install some graphical tools and snap-ins on Windows Core Server 2019 (MMC, Eventvwr, Hyper-V Manager, PerfMon, Resmon, Explorer.exe, Device Manager, Powershell ISE). You can download FOD as an ISO file if your Microsoft subscription is active. You can install it as follows:
Add-WindowsCapability -Online -Name ServerCore.AppCompatibility~~~~0.0.1.0
Server Core App Compatibility Feature on Demand installation will use about 200 MB of additional RAM on your Server Core.
In this article, I tried to collect the most useful commands needed to administer Windows Server Core. From time to time, I will update the article and add new commands if they seem necessary for everyday work.