我正在运行Powershell脚本来安装IIS。下面是我的脚本
Add-WindowsFeature NET-Framework-45-ASPNET
Add-WindowsFeature NET-HTTP-Activation
Add-WindowsFeature Telnet-Client
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServer
Enable-WindowsOptionalFeature -Online -FeatureName IIS-CommonHttpFeatures
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpErrors
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpRedirect
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationDevelopment
Enable-WindowsOptionalFeature -Online -FeatureName IIS-NetFxExtensibility45
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HealthAndDiagnostics
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpLogging
Enable-WindowsOptionalFeature -Online -FeatureName IIS-LoggingLibraries
Enable-WindowsOptionalFeature -Online -FeatureName IIS-RequestMonitor
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpTracing
Enable-WindowsOptionalFeature -Online -FeatureName IIS-Security
Enable-WindowsOptionalFeature -Online -FeatureName IIS-RequestFiltering
Enable-WindowsOptionalFeature -Online -FeatureName IIS-Performance
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerManagementTools
Enable-WindowsOptionalFeature -Online -FeatureName IIS-IIS6ManagementCompatibility
Enable-WindowsOptionalFeature -Online -FeatureName IIS-Metabase
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ManagementConsole
Enable-WindowsOptionalFeature -Online -FeatureName IIS-BasicAuthentication
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WindowsAuthentication
Enable-WindowsOptionalFeature -Online -FeatureName IIS-StaticContent
Enable-WindowsOptionalFeature -Online -FeatureName IIS-DefaultDocument
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebSockets
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationInit
Enable-WindowsOptionalFeature -Online -FeatureName IIS-NetFxExtensibility45
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET45
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIExtensions
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIFilter
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpCompressionStatic
Add-WindowsFeature Web-Scripting-Tools
Add-WindowsFeature MSMQ
Add-WindowsFeature msmq-server, msmq-triggers
Add-WindowsFeature Web-Ftp-Server
我收到错误
Enable-WindowsOptionalFeature:禁用了一个或多个父功能,因此无法启用当前功能。 在C:\ SetupScripts \ Install-IIS.ps1:34 char:1 + Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET45 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ + CategoryInfo:未指定:(:) [Enable-WindowsOptionalFeature],COMException + FullyQualifiedErrorId:Microsoft.Dism.Commands.EnableWindowsOptionalFeatureCommand
我在这里做错了什么?确定有问题吗?
答案 0 :(得分:0)
我以前也遇到过同样的问题。我只需运行PowerShell as Administrator
就解决了。即使从提升的PowerShell运行后,如果仍然抛出错误,也请尝试
Install-WindowsFeature -name Web-Server -IncludeManagementTools
Set-ExecutionPolicy Bypass -Scope Process
答案 1 :(得分:0)
我只是遇到了同样的问题,发现在安装IIS-ISAPIExtensions
之前必须先安装IIS-ISAPIFilter
和IIS-ASPNET45
。换句话说:
...
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIExtensions
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIFilter
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET45
...
我不知道找到其他功能的父功能的任何简便方法。如果它是从Get-WindowsOptionalFeature
答案 2 :(得分:0)
尝试在最后添加选项-全部。 All参数在启用指定功能之前启用指定功能的所有父功能。父功能将启用默认值
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET45 -All
也请参阅 https://docs.microsoft.com/en-us/powershell/module/dism/enable-windowsoptionalfeature?view=win10-ps
答案 3 :(得分:0)
您可以通过在脚本中添加以下内容来完成它
Enable-WindowsOptionalFeature -online -FeatureName NetFx4Extended-ASPNET45