Thursday, 23 January 2014


This script creates a function to display a message
in a message block, then demonstrates its usage
This script used Windows Forms to put up a message
box containing text and a window title passed as
File Name : Show-Message.ps1
Author : Thomas Lee -
Requires : PowerShell Version 3.0
This script posted to:
Left as an exercise to the Reader

Function Show-Message {

Param (
HelpMessage="Content of Message box")]
[string]$Message ,

HelpMessage="Title for Message box")]
[string]$BoxTitle = "Message"

# just in case, load the relevant assembly
$v1 = [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

# now use the messagebox class to display the message
[Windows.Forms.MessageBox]::Show($Message, $BoxTitle,
[Windows.Forms.MessageBoxButtons]::OK ,

} # End of function

# Set an alias
Set-Alias sm Show-Message

# call the function
sm 'testing' 'details, details'

1 comment:

Doe John said...

This is pretty sweet. Thanks man!