########################### ### IIS Web Server Prepare ### Version: 2.2 ########################### ########################### ### Check if admin ########################### If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(` [Security.Principal.WindowsBuiltInRole] "Administrator")) { Write-Warning "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!" Break } ########################### ### Download Choco ########################### Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) ########################### ### Choco for generic servers ########################### choco install -y --ignore-checksums chocolatey chocolatey-core.extension chocolatey-windowsupdate.extension chocolateygui notepadplusplus.install 7zip.install putty.install sysinternals procexp curl windirstat autoruns latencymon openhardwaremonitor processhacker.install cpu-z gpu-z lockhunter pstools wget openssl.light keystore-explorer.portable filezilla bginfo wireshark nmap bleachbit vcredist2005 vcredist2008 vcredist2010 gsmartcontrol vcredist2012 s3put hijackthis virustotaluploader pci-z lessmsi cmder wsus-offline-update hashtab opera dotnet4.7 aspnetmvc4.install ########################### ### # Disable IPv6 from registry ########################### New-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\' -Name 'DisabledComponents' -Value '0xffffffff' -PropertyType 'DWord' ########################### ### Enable Task Scheduler history (requires restart) ########################### $logName = 'Microsoft-Windows-TaskScheduler/Operational' $log = New-Object System.Diagnostics.Eventing.Reader.EventLogConfiguration $logName $log.IsEnabled=$true $log.SaveChanges() ########################### ### Choco for IIS servers ########################### choco install -y --ignore-checksums iiscrypto webdeploy webpicmd ########################### ### Install IIS features ########################### # Dotnet 2.0, 3.0, 3.5, 4.6 # Telnet and WAS # IIS and WebDAV $IISFeatures = "WebDAV-Redirector","WAS","Telnet-Client","Web-WHC","NET-Framework-Features","NET-Framework-45-Features","Web-Mgmt-Console","Web-Scripting-Tools","Web-Mgmt-Service","Web-Server" Install-WindowsFeature -Name $IISFeatures -IncludeAllSubFeature $FeaturesToRemove = "Web-Ftp-Server","Web-Ftp-Service","Web-Ftp-Ext" Uninstall-WindowsFeature -Name $FeaturesToRemove WebPICMD.exe /Install /Products:MVC2 /AcceptEula /SuppressReboot WebPICMD.exe /Install /Products:MVC3Runtime /AcceptEula /SuppressReboot WebPICMD.exe /Install /Products:UrlRewrite2 /AcceptEula /SuppressReboot choco install -y dotnetcore-sdk ########################### ### Remove default IIS apps ########################### Remove-Website -Name "Default Web Site" $defaultAppPools = @(".NET v2.0",".NET v2.0 Classic",".NET v4.5",".NET v4.5 Classic","Classic .NET AppPool","DefaultAppPool") Foreach ($defaultAppPool in $defaultAppPools){ IF (Test-path "IIS:\AppPools\$defaultAppPool"){Remove-WebAppPool -name $DefaultAppPool} } ########################### ### Change IIS log location ########################### #$NewFolders = "inetpub", "inetpub\apps", "logs" #$NewFolders | ForEach-Object {New-Item E:\$_ -type directory} #Import-Module WebAdministration #Set-WebConfigurationProperty "/system.applicationHost/sites/siteDefaults" -name logfile.directory -value E:\logs ########################### ### Activate Windows license in AWS ########################### Set-ExecutionPolicy Unrestricted -force PowerShell -Command "& {Import-Module C:\ProgramData\Amazon\EC2-Windows\Launch\Module\Ec2Launch.psm1 ; Add-Routes}" slmgr /ato ########################### ### Disable Windows autoupdates ########################### New-Item HKLM:\SOFTWARE\Policies\Microsoft\Windows -Name WindowsUpdate New-Item HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate -Name AU New-ItemProperty HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU -Name NoAutoUpdate -Value 1 ########################### ### Rename Computer ########################### $temp_Date = Get-Date -UFormat "%H%d%m%Y" Rename-Computer -NewName "IIS-$temp_Date" ########################### ### Make the required restart ########################### #Restart-Computer -Force