Here is how, for example:
$null = [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
function Message-Box(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[string] $message, [string] $header=$null,
[switch][bool]$error = $false) {
$icon = [System.Windows.Forms.MessageBoxIcon]::Information
if ($error) { $icon = [System.Windows.Forms.MessageBoxIcon]::Error }
$null = [System.Windows.Forms.MessageBox]::Show($message, $header, [System.Windows.Forms.MessageBoxButtons]::OK, $icon)
} # Message-Box
# use it:
<pre lang="text">message-box "Some message" -header " Some (optional) header"
or
"Some message" | message-box -header " Some (optional) header"
or, for error icon (see implementation of the function):
message-box "Some error message" -header " Some (optional) header" -error
# [switch] attribute shows that the value is not used in command line
Enjoy,
—SA