PowerShell PopUp Window

PowerShell PopUp Window

To create a PowerShell PopUp Window can be achieved in just two lines of code as below

$wshell = New-Object -ComObject Wscript.Shell
$Output = $wshell.Popup(“The report generation script is successfully completed!”)

You can take this further by getting feedback from the user and adding a bit of logic to the code

#Button Types  
#Value  Description   
#0 Show OK button. 
#1 Show OK and Cancel buttons. 
#2 Show Abort, Retry, and Ignore buttons. 
#3 Show Yes, No, and Cancel buttons. 
#4 Show Yes and No buttons. 
#5 Show Retry and Cancel buttons. 

$ButtonType = 4
$Timeout = 60
$Confirmation = New-Object -ComObject wscript.shell
$ConfirmationAnswer = $Confirmation.popup("What are you going to click?",$Timeout,"Make you're choice",$ButtonType)
If ($ConfirmationAnswer -eq 6) { 
    $Confirmation.popup("You clicked yes.") 
} else { 
    $Confirmation.popup("You clicked no.") 
what are you going to click
PowerShell Pop-up prompt with logc
you clicked yes
Prompt on user input

Found priceless insights in this blog? Support the author’s creativity – buy them a coffee!

Leave a Reply

Your email address will not be published. Required fields are marked *