<powershell>

# Disable .Net Optimization Service
Get-ScheduledTask *ngen* | Disable-ScheduledTask

# Disable Windows Auto Updates
# https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/troubleshooting-windows-instances.html#high-cpu-issue
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUOptions /t REG_DWORD /d 1 /f
net stop wuauserv
net start wuauserv

# Disable Windows Defender Monitoring
Set-MpPreference -DisableRealtimeMonitoring $true

# Disable Firewall
Set-NetFirewallProfile Domain,Public,Private -Enabled false

# Enable WinRM
Invoke-WebRequest -Uri https://raw.githubusercontent.com/ansible/ansible-documentation/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 -OutFile C:\ConfigureRemotingForAnsible.ps1
C:\ConfigureRemotingForAnsible.ps1 -ForceNewSSLCert -EnableCredSSP

# add ec2-user
$Password = ConvertTo-SecureString 'KitFE.!5$(yhR9xli)73Mqw)r0BoWahc' -AsPlainText -Force
New-LocalUser -Name "ec2-user" -Description "Ansible Service Account" -Password $Password
Add-LocalGroupMember -Group "Administrators" -Member "ec2-user"

# Enable Samba Server
Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol

</powershell>
