If a reboot is required for an application installation, you should likely attempt to force the device to reboot using the, “Should Configuration Manager enforce specific behavior regardless of the application’s intended behavior” drop-down menu in the Deployment Type settings.
Unfortunately, depending on client settings, you may experience a deferred restart.
If you are keen to bypass this and restart the device anyway, perhaps for an urgent overnight installation, it can be done from within a Powershell script, but in a not-so-obvious way. Please note that this should only be done with extreme caution and only if the circumstances allow/permit. If the client is deferring a restart, there is likely a reason. You can read more on device restart deferral and notifications here:
https://docs.microsoft.com/en-us/mem/configmgr/core/clients/deploy/device-restart-notifications
Using the Restart-Computer cmdlet is the obvious go-to, but it will not work as expected. It will restart the computer, however, you will receive an execution failure code. When the restart is executed from within the script, it will occur almost immediately. Because of this, the script will not exit satisfactorily, and will return an execution failure code (1073807364).
This can be observed in the CCM AppEnforce.log file as well.
The way to get around this is conveniently built into Windows: shutdown.exe. As an executable, it is “triggered” from within the script, but runs independently of it. This means our script can exit in healthy manner- all the while shutdown.exe is running in a parallel fashion. Shutdown.exe also has a built-in timer switch. Using the /t switch, you can specify the amount of delay in seconds.
So, for example, your script might look like:
Start-Process -Wait -FilePath “Install.exe” -ArgumentList “-silent”
Shutdown.exe /r /f /t 30
Admittedly, this is less-than-ideal, because your script could potentially fail for some unforeseen reason, and the device would still reboot. But, a bit of caution when implementing your detection logic in MECM will ensure you can detect success/failure regardless.