Installation will still proceed when i click No button for Show-DialogBox

i have this below line and when i click ‘No’ button , installation will still proceed.

Show-DialogBox -Title “Installation Update” -Text “This installation will take less than 2 minutes and all existing sessions will be force closed during the process. Do you want to proceed?” -Buttons “YesNo” -Icon “Exclamation”

The way the dialog boxes work isn’t 100% clear. You need to assign a variable to the dialog box and then evaluate that. Similar to the below.

$proceed = Show-DialogBox -Title “Installation Update” -Text “This installation will take less than 2 minutes and all existing sessions will be force closed during the process. Do you want to proceed?” -Buttons “YesNo” -Icon “Exclamation”
If ($proceed -eq 'No') {
Write-Log -Message 'Exit scipt because user selected no.'
Exit-Script
}

thank you, it worked. i understand now.