Answered by:
Removing yes/no prompt from hyper-v installation

Question
-
Hi.
I have been trying to make a PowerShell script to enable Microsoft Hyper V Hypervisor.
The script is working as intended, but everytime I run the script i get asked if i want to restart the computer.
Is there any way i can add to the script so that it auto-replies yes to the restart prompt?
Here is the script i have so far:
Enable-WindowsOptionalFeature -Online -FeatureName:Microsoft-Hyper-V-Hypervisor -all
Wednesday, March 7, 2018 9:13 AM
Answers
-
If you do not want a restart after the installation just add the -NoRestart parameter. If you would like to restart after the installation you can do something like this:
Enable-WindowsOptionalFeature -Online -FeatureName:Microsoft-Hyper-V-Hypervisor -All -NoRestart; Restart-Computer
I've tried, and it worked.
MCSE, MCSA, MS, MCP, MCTS, System Engineer
- Proposed as answer by Martien van Dijk Wednesday, March 7, 2018 9:46 AM
- Marked as answer by Zhilay Thursday, March 8, 2018 7:47 AM
Wednesday, March 7, 2018 9:39 AM
All replies
-
No sure if you can use the -Confirm parameter for this but it might be worth adding -Confirm:TRUE
You could also add another part to the script that restarts the computer after a little bit of time.
Wednesday, March 7, 2018 9:36 AM -
If you do not want a restart after the installation just add the -NoRestart parameter. If you would like to restart after the installation you can do something like this:
Enable-WindowsOptionalFeature -Online -FeatureName:Microsoft-Hyper-V-Hypervisor -All -NoRestart; Restart-Computer
I've tried, and it worked.
MCSE, MCSA, MS, MCP, MCTS, System Engineer
- Proposed as answer by Martien van Dijk Wednesday, March 7, 2018 9:46 AM
- Marked as answer by Zhilay Thursday, March 8, 2018 7:47 AM
Wednesday, March 7, 2018 9:39 AM -
I was writing the same reply as Matej:)
Sincerely, Martien van Dijk. Please remember to mark the replies as answers if they help and unmark them if they provide no help. Check out My Blog!
Wednesday, March 7, 2018 9:46 AM -
Testet it, and it worked perfectly. Thank you!Thursday, March 8, 2018 7:48 AM