我正在使用 power shell 脚本在 Windows 10 Pro 机器上安装 IIS。我正在使用这篇博客文章来创建脚本。
该脚本安装具有以下核心的 IIS。
# * Make sure you run this script from a Powershel Admin Prompt!
# * Make sure Powershell Execution Policy is bypassed to run these scripts:
# * YOU MAY HAVE TO RUN THIS COMMAND PRIOR TO RUNNING THIS SCRIPT!
Set-ExecutionPolicy Bypass -Scope Process
# To list all Windows Features: dism /online /Get-Features
# Get-WindowsOptionalFeature -Online
# LIST All IIS FEATURES:
# Get-WindowsOptionalFeature -Online | where FeatureName -like 'IIS-*'
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
我已经在 DevOps 上完成了任务:
一切正常,但是今天我开始部署时,开始出现错误
Enable-WindowsOptionalFeature :Windows PowerShell 处于非交互模式。阅读和提示功能不可用。在 C:\azagent\A1_work_temp\af294c00-d96a-4b04-b507-e2e3afcbee4f.ps1:12 char:1 + Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole + ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~ + CategoryInfo : InvalidOperation: (:) [Enable-WindowsOptionalFeature], PSInvalidOperationException + FullyQualifiedErrorId : InvalidOperation,Microsoft.Dism.Commands.EnableWindowsOptionalFeatureCommand
PowerShell 以代码“1”退出。
我已经检查了 get-ExecutionPolicy,这是unrestricted并 $confirmpreference设置为High。
为什么我在前一天工作正常时会收到此错误?
这可能是由于 Windows 更新造成的吗?我该如何解决这个问题?
