NebDaMin
NebDaMin

Reputation: 658

Windows 8 Powershell Enable-WindowsOptionalFeature bat file

I have a .bat file that runs a powershell script. This is it

powershell -Command "& {Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole}"

I have done this before and if I wanted to add another command I would put a semicolon before the closing brace and continue the script.

This command however after completed requires that I choose wheter or not to restart the computer with a Y or N.

enter image description here

Does anyone know how to pass this in an argument or avoid this step all together?

Thanks in advance

Note: you have to run the .bat file as adminstrator

Upvotes: 1

Views: 1695

Answers (1)

rtf
rtf

Reputation: 745

From Get-Help Enable-WindowsOptionalFeature -Full:

 -NoRestart [<SwitchParameter>]
     Suppresses reboot. If a reboot is not required, this command does nothing. This option will keep the
     application from prompting for a restart or keep it from restarting automatically.

Add the -NoRestart flag to Enable-WindowsOptionFeature to suppress the reboot. If you do want to reboot after completion, use the command Restart-Computer.

Upvotes: 2

Related Questions