Which of the below CmdLet will display a Pop Window in Powershell?
-
$a = new-object -comobject wscript.Window $intAnswer = $a.popup("This is a Pop up?",0,"Select Option",3)
-
$a = new-object -comobject wscript.shell $intAnswer = $a.Window("This is a Pop up?",0,"Select Option",4)
-
$a = new-object -comobject wscript.shell $intAnswer = $a.popup("This is a Pop up?",0,"Select Option",4)
-
$a = new-object -comobject wscript.shell $intAnswer = $a.Window("This is a Pop up?",0,"Select Option",5)
C
Correct answer
Explanation
The correct code uses wscript.shell COM object and calls the popup method with the message text, timeout (0 seconds), title, and button type (4 = Yes/No). Options A uses wscript.Window (wrong object), B and D use .Window method instead of .popup. Option C has the correct COM object (wscript.shell) and correct method (popup).