Async Show-InstallationPrompt without Buttons. How to close it?

If you take Example 3 in the documentation:

Show-InstallationPrompt -Message 'You can customize text to appear at the end of an install, or remove it completely for unattended installations.' -Icon Information -NoWait

it opens an async InstallationPrompt with no buttons. But how can you ever close this one??? Even after the whole script finishes, this stays open forever. You cannot X it away, it immediately reopens itself.

I’d use that for prompting to plug in AC. It should go away after AC is connected. (Test-Battery etc…)

For Show-InstallationPrompt, buttons are optional.
Use the one of the -ButtonXXXXText parameters like -ButtonLeftText

Can you at least read the headline, please? How to close it?
Example 3 in the documentation. How do you close this one?

remove the -NoWait.

-NoWait tell the script to spawn another instance of PSADT just to display the popup, meanwhile the first instance of PSADT goes to the next line.

you’ll probably want to nag the user until they plug in so you’d have to do something like this:

While ((Test-Battery -PassThru).ACPowerLineStatus -ne 'Online') {
	$response =	Show-InstallationPrompt -Message "Please plug in AC power source to continue installation" -ButtonRightText 'OK' -ButtonLeftText 'Cancel installation' -Icon Information
	If ($response -eq 'Cancel installation') { Exit-Script -ExitCode 1}
}

Ok this will work nicely, thank you!

Also it now makes sence with the NoWait parameter. However, Example 3 in the documentation should be removed there, because it will result in a second PSADT popup that will never close, except you find this process in the Taskmanager, and kill it there.

1 Like