I am writing a powershell script for enabling some Windows Features. It looks like something like this:
...
Enable-WindowsOptionalFeature -Online -FeatureName "IIS-WebServerRole"
Enable-WindowsOptionalFeature -Online -FeatureName "IIS-WebServer"
Enable-WindowsOptionalFeature -Online -FeatureName "IIS-FTPServer"
...
In this script, there are multiple commands where I enable windows features which require a restart. So what I noticed is that in powershell it's enabling stuff, and then the last 4 lines where I enable stuff that requires restart, it's constantly prompting me to restart the computer in powershell. So I have to constantly say "No" because otherwise it'll restart the computer before all the commands in the script are executed:
My question is, in my script, how do I wait until all commands are executed, and only then have a prompt about restarting my PC? I tried adding "Wait-Process" and "-Wait" tags to the commands, but I got errors like this:

Does anyone know a way I could wait for all the commands to execute and only then have a restart prompt? Thanks in advance!
