#region Detect Windows Features and support modules Write-Host "Enable Needed windows features" $local:neededWindowsFeatures = @( "NetFx4","NetFx4Extended-ASPNET45","IIS-WebServerRole","IIS-WebServer","IIS-CommonHttpFeatures","IIS-Security","IIS-RequestFiltering","IIS-StaticContent","IIS-DefaultDocument", "IIS-DirectoryBrowsing","IIS-HttpErrors","IIS-HttpRedirect","IIS-ApplicationDevelopment","IIS-WebSockets","IIS-ApplicationInit","IIS-NetFxExtensibility45","IIS-ISAPIExtensions", "IIS-ISAPIFilter","IIS-ASPNET45","IIS-HealthAndDiagnostics""IIS-HttpLogging","IIS-RequestMonitor","IIS-BasicAuthentication","IIS-WindowsAuthentication","IIS-IPSecurity", "IIS-Performance","IIS-HttpCompressionStatic","IIS-WebServerManagementTools","IIS-ManagementConsole","IIS-ManagementScriptingTools","IIS-ManagementService","WAS-WindowsActivationService", "MSMQ","MSMQ-Services","WCF-Services45","WCF-HTTP-Activation45","WCF-TCP-Activation45","WCF-MSMQ-Activation45","WCF-TCP-PortSharing45","Web-AppInit" ) Get-WindowsOptionalFeature -Online | Where-Object -Property FeatureName -In $local:neededWindowsFeatures | Where-Object -Property State -NE "Enabled" | % { Write-Host "Enable Needed Windows Feature : $($_.FeatureName)"; Enable-WindowsOptionalFeature -Online -All -FeatureName $_.FeatureName |Out-Null }