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:
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With