【问题标题】:Azure pipeline error 'Windows PowerShell is in NonInteractive mode.'Azure 管道错误“Windows PowerShell 处于非交互模式。”
【发布时间】:2019-08-31 10:35:00
【问题描述】:

我正在使用 power shell 脚本在 Windows 10 Pro 机器上安装 IIS。 我正在使用这个blog post 创建脚本。

该脚本安装具有以下核心的 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 更新造成的吗?我该如何解决这个问题?

【问题讨论】:

  • 奇怪!可能是它提示某种子操作,比如期待重新启动或类似的东西。您可以尝试在每个 Enable-WindowsOptionalFeature 命令的末尾添加“-Force -Confirm:$false”吗?
  • 嘿@KrishnaG-MSFT,我刚刚重新启动,现在一切正常。肯定有点奇怪

标签: powershell tfs azure-devops devops azure-pipelines


【解决方案1】:

正如评论所说:错误消息表明您的命令之一正在尝试提示用户确认。如果是Enable-WindowsOptionalFeature,它可能会提示重启。

通常您可以通过在 Powershell 命令中添加 -Force-Confirm:$false 来取消提示。

另外,Enable-WindowsOptionalFeature-NoRestart flag,这应该会阻止它提示重新启动。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    • 2021-12-29
    • 1970-01-01
    • 1970-01-01
    • 2015-08-26
    • 2016-05-22
    • 2017-03-08
    相关资源
    最近更新 更多