PowerShell’s Answer to VBscript’s Msgbox

Adam Bertram

Adam Bertram

Read more posts by this author.

Remember Vbscript? I do but I’d rather not.

I’ll give VBscript credit though. It got me through a lot of problems that I otherwise had to have written batch files (GASP!) to accomplish. VBscript had a function called Msgbox. It was a neat, little function that popped up an information box like so.

VBScript msgbox
VBScript msgbox

Now that we’ve graduated to only writing PowerShell scripts how can we get this gem back? It turns out that Powershell can hang around with the VBscript dudes on the wrong side of the tracks and actually perform the exact same function. Using a COM object, PowerShell can simply called the PopUp() method and voila we have a MsgBox again only this time with Powershell.

$a = new-object -comobject wscript.shell
$a.popup("You are using Powershell $($psversiontable.psversion.Major)",0,"Powershell",0)
PowerShell msgbox
PowerShell msgbox

Subscribe to Adam the Automator

Get the latest posts delivered right to your inbox

Looks like you're offline!