windows server core - survival guide

https://www.mssqltips.com/sqlservertip/2642/installing-sql-server-2012-on-windows-server-core-part-1/

Basic server configuration

sconfig - perform basic server configuration like changin computer name, deal with network ip addresses, setup updates etc.

Languages

List installed languages

Get-WinUserLanguageList

Set languages to english only

Set-WinUserLanguageList -LanguageList en-US -Force

Notice: before removing unwanted keyboard languages make sure that your password is not in that langugage

Region and Date Time

c:\windows\system32\intl.cpl

Set new password

net user administrator P@ssword

optionally you may need to activate user if running container:

net user administrator /active:yes

Adding new admin account

net user /add mac P@ssword
net localgroup administrators mac /add

Rename network adapters

List available network adapters

Get-NetAdapter

Determine required interface index

Get-NetIPAddress -AddressFamily IPv4 | Select-Object InterfaceIndex, IPAddress, PrefixOrigin
Rename-NetAdapter -Name 'Ethernet' -NewName 'LAN'
Rename-NetAdapter -Name 'Ethernet 2' -NewName 'WAN'

Add domain user to local administrators group

net localgroup Administrators /add RABOTA\AlexandrM

Disable IPv6

Disable-NetAdapterBinding -InterfaceAlias Ethernet -ComponentID ms_tcpip6

Set PATH

SETX /M PATH "%PATH%;C:\your path with spaces"

/M - adds path to machine, without it user path will be modified

Cleanup and analyze disk

Dism.exe /online /Cleanup-Image /AnalyzeComponentStore
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase

Get disk space

$c = get-wmiobject Win32_LogicalDisk |? DeviceID -EQ 'C:'
($c.Size - $c.FreeSpace) / 1Gb

Measure disk speed

winsat disk -drive c

Optimize VHD (reduce vhdx file size)

Turn off VM

Attach VHD to your host machine

run sdelete (https://technet.microsoft.com/en-us/sysinternals/sdelete.aspx)

sdelete -s -z e:

Defragment drive

In drive management shrink disk as much as possible

Get-VM | Get-VMHardDiskDrive | Optimize-VHD -Mode Full

Firewall

Allow certain port

New-NetFirewallRule -DisplayName "Postgres" -Direction Inbound -Protocol TCP -LocalPort 5432 -Action Allow

Allow RDP

Enable-NetFirewallRule -DisplayGroup “Remote Desktop”

Allow ICMP

netsh firewall set icmpsetting 8

Turnoff Firewall

Get-NetFirewallProfile | Set-NetFirewallProfile -enabled false

Environment Variables

[Environment]::SetEnvironmentVariable('JAVA_HOME', 'C:\jre', 'MACHINE')

$old_path = [Environment]::GetEnvironmentVariable('PATH', 'MACHINE')

[Environment]::SetEnvironmentVariable('PATH', "$old_path;C:\jre\bin", 'MACHINE')

Software

JRE

# Command line installation options: http://docs.oracle.com/javase/8/docs/technotes/guides/install/config.html

# Download link can be found here (look for Windows Offline 64-bit): http://www.java.com/en/download/manual.jsp

cd ~/Downloads

Invoke-WebRequest 'http://javadl.oracle.com/webapps/download/AutoDL?BundleId=207231' -OutFile jre-8u77-windows-x64.exe

.\jre-8u77-windows-x64.exe INSTALL_SILENT=Enable STATIC=Enable AUTO_UPDATE=Disable NOSTARTMENU=Enable

$jre = Get-ChildItem 'C:\Program Files\Java' | Sort-Object Name | Select-Object -ExpandProperty Name -First 1

$java_home = "C:\Program Files\Java\$jre"

$java_bin = "$java_home\bin"

$old_path = [Environment]::GetEnvironmentVariable('PATH', 'MACHINE')

[Environment]::SetEnvironmentVariable('JAVA_HOME', $java_home, 'MACHINE')

[Environment]::SetEnvironmentVariable('PATH', "$old_path;$java_bin", 'MACHINE')

Restart-Computer -Force

java -version