PS | Initial Setup for New Windows Server

< All Topics

Refer to the PowerShell Script below on how to perform initial setup for new Windows Server


Set Timezone to Malaysia

$TimeZone = "Malay Peninsula Standard Time"
Set-TimeZone -Name $TimeZone

IPv4 priority over IPv6

#Pefer IPv4 over IPv6
New-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters" -Name DisabledComponents¬Ě -Value 0x20 -PropertyType Dword

Enable Remote Desktop

#Enable Remote Desktop 
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server' -Name "fDenyTSConnections" -Value 0

Firewall Rules

Refer to Manage Windows Firewall with PowerShell for more detail information

#Allow Ping 
New-NetFirewallRule -DisplayName "Allow inbound ICMPv4" -Direction Inbound -Protocol ICMPv4 -IcmpType 8 -Action Allow
#Allow inbound RDP 
Set-NetFirewallRule -DisplayGroup "Remote Desktop" -Enabled True
#File Sharing - Optional 
Set-NetFirewallRule -DisplayGroup "File And Printer Sharing" -Enabled True

Static IP Address & DNS Server

$Interface = "ethernet0"
$IPv4 = ""
$Prefix = "24"
$DefaultGateway = ""
$DNSServer = ""

#Change IP Address
New-NetIPAddress -InterfaceAlias $Interface -IPAddress $IPv4 -PrefixLength $Prefix -DefaultGateway $DefaultGateway
#DNS Client
Set-DnsClientServerAddress -InterfaceAlias $Interface -ServerAddresses $DNSServer

Windows Update

Refer to Manage Windows Update with PowerShell for more detail information

Install-Module PSWindowsUpdate 
Install-WindowsUpdate -AcceptAll -Install -IgnoreReboot | Out-File "c:\Logs\$(get-date -f yyyy-MM-dd)-WindowsUpdate.log" -force

PowerShell as Default Shell

Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name Shell -Value 'PowerShell.exe -NoExit'

Minimal GUI

Install Windows Server 2019 Core Feature on Demand for App Compatibility to have additional GUI Tool for management in Server Core

Download App Compatibility FOD from Microsoft Volume License Site

Initial Setup for New Windows Server

Upload the ISO file to C:\Temp\FOD.iso on Windows 2019 Server Core and install it

Mount-DiskImage -ImagePath C:\temp\FOD.ISO
Add-WindowsCapability -Online -Name ServerCore.AppCompatibility~~~~ -Source:E: -LimitAccess
#Reboot once completed

Additional GUI Tool, like Group Policy Management can be used in Server Core now.

Previous PS | Functions
Next PS | List Inactive AD Users and Computers for Past X Days
Table of Contents