PowerShell Script to Harden a Windows 2019 Server to HITRUST Cybersecurity Standards

 HITRUST is a cybersecurity framework that aims to protect sensitive information and manage risks in the healthcare industry. Hardening a Windows Server 2019 to meet HITRUST standards involves implementing a range of security controls to ensure the confidentiality, integrity, and availability of the system and the data it processes.


Here's a PowerShell script that you can use to harden a Windows Server 2019 to HITRUST standards:

# Disable SMBv1
Disable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol

# Enable SMBv2 and SMBv3
Set-SmbServerConfiguration -EnableSMB2Protocol $true
Set-SmbServerConfiguration -EnableSMB3Protocol $true

# Disable NetBIOS over TCP/IP
Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object { $_.TcpipNetbiosOptions -ne 0 } | ForEach-Object {
    $_.DisableNetbios()
}

# Enable Windows Defender
Set-MpPreference -DisableRealtimeMonitoring $false
Set-MpPreference -DisableBehaviorMonitoring $false
Set-MpPreference -DisableBlockAtFirstSeen $false

# Enable Windows Firewall
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
Set-NetFirewallRule -DisplayGroup 'File and Printer Sharing' -Enabled True
Set-NetFirewallRule -DisplayGroup 'Remote Administration' -Enabled True
Set-NetFirewallRule -DisplayGroup 'Remote Desktop' -Enabled True
Set-NetFirewallRule -DisplayGroup 'Windows Management Instrumentation (WMI)' -Enabled True

# Configure audit policy
$auditPolicy = Get-AuditPolicy
$auditPolicy.AuditLogonEvents = "Success,Failure"
$auditPolicy.AuditObjectAccess = "Success,Failure"
$auditPolicy.AuditProcessTracking = "Success"
$auditPolicy.AuditPolicyChange = "Success"
$auditPolicy.AuditSystemEvents = "Success"
Set-AuditPolicy -InputObject $auditPolicy

# Disable LM and NTLMv1 authentication
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa' -Name 'LMCompatibilityLevel' -Value 5
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa' -Name 'LmCompatibilityLevel' -Value 5
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0' -Name 'NtlmMinClientSec' -Value 5376
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0' -Name 'NtlmMinServerSec' -Value 5376

# Enable Secure LDAP (LDAPS)
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\LDAP' -Name 'LDAPServerIntegrity' -Value 2

# Disable anonymous access to shares
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters' -Name 'NullSessionShares' -Value ''

# Disable unnecessary services
Get-Service -Name RemoteRegistry | Set-Service -StartupType Disabled
Get-Service -Name Telnet | Set-Service -StartupType Disabled
Get-Service -Name TFTP | Set-Service -StartupType Disabled
Get-Service -Name SNMP | Set-Service -StartupType Disabled
Get-Service -Name SNMPTRAP | Set-Service -StartupType Disabled

# Install the latest security updates
Install-PackageProvider -Name NuGet -MinimumVersion 2

Comments

Popular posts from this blog

Unveiling the Power of PowerShell Regions: A Comprehensive Guide

PowerShell Script to Remotely Update Firmware on Brother Printers Microsoft

PowerShell Script to Reset Permissions on all Documents in a Document Library in SharePoint Online.