windows server core - survival guide
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-WinUserLanguageListSet languages to english only
Set-WinUserLanguageList -LanguageList en-US -ForceNotice: before removing unwanted keyboard languages make sure that your password is not in that langugage
Region and Date Time
c:\windows\system32\intl.cplSet new password
net user administrator P@sswordoptionally you may need to activate user if running container:
net user administrator /active:yesAdding new admin account
net user /add mac P@ssword
net localgroup administrators mac /addRename network adapters
List available network adapters
Get-NetAdapterDetermine required interface index
Get-NetIPAddress -AddressFamily IPv4 | Select-Object InterfaceIndex, IPAddress, PrefixOriginRename-NetAdapter -Name 'Ethernet' -NewName 'LAN'
Rename-NetAdapter -Name 'Ethernet 2' -NewName 'WAN'Add domain user to local administrators group
net localgroup Administrators /add RABOTA\AlexandrMDisable IPv6
Disable-NetAdapterBinding -InterfaceAlias Ethernet -ComponentID ms_tcpip6Set 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 /ResetBaseGet disk space
$c = get-wmiobject Win32_LogicalDisk |? DeviceID -EQ 'C:'
($c.Size - $c.FreeSpace) / 1GbMeasure disk speed
winsat disk -drive cOptimize 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 FullFirewall
Allow certain port
New-NetFirewallRule -DisplayName "Postgres" -Direction Inbound -Protocol TCP -LocalPort 5432 -Action AllowAllow RDP
Enable-NetFirewallRule -DisplayGroup “Remote Desktop”Allow ICMP
netsh firewall set icmpsetting 8Turnoff Firewall
Get-NetFirewallProfile | Set-NetFirewallProfile -enabled falseEnvironment 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