POWERSHELL 40
IISPrep v3.0 Guest on 1st October 2019 02:50:50 PM
  1. ###########################
  2. ### IIS Web Server Prepare
  3. ### Version: 3.0
  4. ###########################
  5.  
  6.  
  7. ###########################
  8. ### Check if admin
  9. ###########################
  10. If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
  11.     [Security.Principal.WindowsBuiltInRole] "Administrator"))
  12. {
  13.     Write-Warning "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!"
  14.     Break
  15. }
  16.  
  17.  
  18. ###########################
  19. ### Download Choco
  20. ###########################
  21. Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
  22.  
  23.  
  24. ###########################
  25. ### Choco for generic servers
  26. ###########################
  27. 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 vcredist-all gsmartcontrol vcredist2012 s3put hijackthis virustotaluploader pci-z lessmsi cmder wsus-offline-update hashtab opera dotnet4.7 aspnetmvc4.install aspnetmvc2 bulk-crap-uninstaller cyberduck googlechrome
  28.  
  29.  
  30. ###########################
  31. ### # Disable IPv6 from registry
  32. ###########################
  33. New-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\' -Name  'DisabledComponents' -Value '0xffffffff' -PropertyType 'DWord'
  34.  
  35.  
  36. ###########################
  37. ### Enable Task Scheduler history (requires restart)
  38. ###########################
  39. $logName = 'Microsoft-Windows-TaskScheduler/Operational'
  40. $log = New-Object System.Diagnostics.Eventing.Reader.EventLogConfiguration $logName
  41. $log.IsEnabled=$true
  42. $log.SaveChanges()
  43.  
  44.  
  45. ###########################
  46. ### Choco for IIS servers
  47. ###########################
  48. choco install -y --ignore-checksums iiscrypto webdeploy webpicmd
  49.  
  50.  
  51. ###########################
  52. ### Install IIS features
  53. ###########################
  54. # IIS, WebDAV, Telnet, WAS, NETFrameworks etc
  55. $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"
  56. Install-WindowsFeature -Name $IISFeatures -IncludeAllSubFeature
  57. #WebPICMD.exe /Install /Products:MVC2 /AcceptEula /SuppressReboot
  58. WebPICMD.exe /Install /Products:MVC3Runtime /AcceptEula /SuppressReboot
  59. WebPICMD.exe /Install /Products:UrlRewrite2 /AcceptEula /SuppressReboot
  60. WebPICMD.exe /Install /Products:ApplicationRequestRouting /AcceptEula /SuppressReboot
  61. choco install -y dotnetcore-sdk
  62.  
  63. ###########################
  64. ### Install DEVOPS01 Features
  65. ###########################
  66. $DEVOPS01 = "FS-FileServer", "File-Service"
  67. Install-WindowsFeature -Name $DEVOPS01 -IncludeAllSubFeature
  68.  
  69.  
  70.  
  71. ###########################
  72. ### Remove default IIS apps
  73. ###########################
  74. Remove-Website -Name "Default Web Site"
  75. $defaultAppPools = @(".NET v2.0",".NET v2.0 Classic",".NET v4.5",".NET v4.5 Classic","Classic .NET AppPool","DefaultAppPool")
  76. Foreach ($defaultAppPool in $defaultAppPools){
  77.     IF (Test-path "IIS:\AppPools\$defaultAppPool"){Remove-WebAppPool -name $DefaultAppPool}
  78. }
  79.  
  80.  
  81. ###########################
  82. ### Disable IIS logging
  83. ###########################
  84. $dontLog = (get-WebConfigurationProperty -PSPath "IIS:\" -filter "system.webServer/httpLogging" -name dontLog).Value
  85. set-WebConfigurationProperty -PSPath "IIS:\" -filter "system.webServer/httpLogging" -name dontLog -value $true
  86. $dontLog = (get-WebConfigurationProperty -PSPath "IIS:\" -filter "system.webServer/httpLogging" -name dontLog).Value
  87.  
  88.  
  89. ###########################
  90. ### Change IIS log location
  91. ###########################
  92. #$NewFolders = "inetpub", "inetpub\apps", "logs"
  93. #$NewFolders | ForEach-Object {New-Item E:\$_ -type directory}
  94. #Import-Module WebAdministration
  95. #Set-WebConfigurationProperty "/system.applicationHost/sites/siteDefaults" -name logfile.directory -value E:\logs
  96.  
  97.  
  98. ###########################
  99. ### Activate Windows license in AWS
  100. ###########################
  101. Set-ExecutionPolicy Unrestricted -force
  102.  PowerShell -Command "& {Import-Module C:\ProgramData\Amazon\EC2-Windows\Launch\Module\Ec2Launch.psm1 ; Add-Routes}"
  103. slmgr /ato
  104.  
  105.  
  106. ###########################
  107. ### Configure Windows NTP settings
  108. ###########################
  109. #w32tm /config /syncfromflags:manual /manualpeerlist:"time.google.com,0.pool.ntp.org,1.pool.ntp.org,2.pool.ntp.org,3.pool.ntp.org"
  110. #w32tm /config /reliable:yes
  111. #net stop w32time
  112. #net start w32time
  113.  
  114.  
  115. ###########################
  116. ### Disable Windows autoupdates
  117. ###########################
  118. New-Item HKLM:\SOFTWARE\Policies\Microsoft\Windows -Name WindowsUpdate
  119. New-Item HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate -Name AU
  120. New-ItemProperty HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU -Name NoAutoUpdate -Value 1
  121.  
  122.  
  123. ###########################
  124. ### Pariplay Firewall rules
  125. ###########################
  126. # Information website
  127. New-NetFirewallrule -displayname Pariplay.Information -direction inbound -action allow -protocol tcp -LocalPort 42001
  128. # Health check website
  129. New-NetFirewallrule -DisplayName Pariplay.Health -Direction inbound -Action allow -Protocol tcp -LocalPort 42002-42020
  130.  
  131.  
  132. ###########################
  133. ### Remove password expiration for Administrator
  134. ###########################
  135. Enable-LocalUser -Name "Administrator"
  136. Set-LocalUser -Name Administrator -PasswordNeverExpires $true -AccountNeverExpires
  137.  
  138.  
  139. ###########################
  140. ### Rename Computer
  141. ###########################
  142. $temp_Date = Get-Date -UFormat "%H%d%m%Y"
  143. Rename-Computer -NewName "IIS-$temp_Date"
  144.  
  145. ###########################
  146. ### Make the required restart
  147. ###########################
  148. Restart-Computer -Force

RSO cPaste е място за публикуване на код или текст за по-лесно отстраняване на грешки.

Влез или се Регистрай за да редактираш, изтриваш или преглеждаш хронология на твоето публикувано съдържание

Необработен текст

Влез или се Регистрирай за да редактираш или задържиш това съдържание.