I have an app that I need to update on all Clients, the app can update just fine silently, if it is not running.
If it is running users will need to close it.
Of course using -Closeapps and AllowDeferCloseApps seems obvious, but this only works if not deployed silently.
Deploying it Interactivly though, will bother all the users who is not currently using the app.
So basically I have to decide which 50% of users I want to bother.
Any way around this limitation, like, deploy silent but show the defer prompt if app is running?
I ended up doing same as you but also checked $UsersLoggedOn and then set $DeployModeSilent to $false so that the Show-InstallationPrompt is displayed.
The net result is a fully automated silent install unless a user is logged on and process running, then show prompt to close app.