Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure pipeline error 'Windows PowerShell is in NonInteractive mode.'

I am installing IIS on a windows 10 Pro machine using power shell script. I am using this blog post to create the script.

The script installs IIS with following core.

# * 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

I have pipelined the task on DevOps:

enter image description here

Everything was working , but today when I started deployment , started getting the error

Enable-WindowsOptionalFeature : Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available. At 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 exited with code '1'.

I have checked get-ExecutionPolicy , which is unrestricted and $confirmpreference set to High.

Why am I getting this error when it was working fine till day before?

Could this be due to windows updates ? How do I get around this issue?

like image 452
Simsons Avatar asked Apr 10 '19 04:04

Simsons


1 Answers

As the comment says: the error message indicates that one of your commands is trying to prompt user for confirmation. In case of Enable-WindowsOptionalFeature, it's probably prompting for reboot.

Usually you can supress prompts by adding -Force and -Confirm:$false to Powershell commands.

Additinaly, Enable-WindowsOptionalFeature has -NoRestart flag, which should prevent it from prompting for reboot.

like image 80
qbik Avatar answered Sep 30 '22 15:09

qbik