-
Notifications
You must be signed in to change notification settings - Fork 1
/
Show-GuiMessageBox.ps1
64 lines (47 loc) · 1.67 KB
/
Show-GuiMessageBox.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function Show-GuiMessageBox {
<#
.SYNOPSIS
Various window pop up configurations
.DESCRIPTION
Displays a popup window with which a non-technical user can interact, with options such as OK, Cancel, YesNo, Error, etc
.PARAMETER Title
A title for the pop up window
.PARAMETER Message
Message or Description for list of items
.PARAMETER Button
Select from available button types
.PARAMETER Icon
Select from available message icons
.NOTES
Icon ENUM: https://docs.microsoft.com/en-us/dotnet/api/system.windows.messageboximage?view=netframework-4.8
Button ENUM: https://docs.microsoft.com/en-us/dotnet/api/system.windows.messageboxbutton?view=netframework-4.8
#>
[CmdletBinding()]
param (
# A title for the pop up window
[Parameter(Position=0)]
[string]
$Title,
# Message or Description for list of items
[Parameter(Position=1)]
[string]
$Message,
# Select from available button types
[Parameter()]
[ValidateSet('OK','OKCancel','YesNo','YesNoCancel')]
$Button = 'OK',
# Select from available message icons
[Parameter()]
[ValidateSet('Asterisk','Error','Exclamation','Hand','Information','None','Question','Warning','Stop')]
$Icon = 'Asterisk'
)
Begin {
Add-Type -AssemblyName PresentationCore,PresentationFramework
}
Process {}
End {
$ButtonType = [System.Windows.MessageBoxButton]::$Button
$MessageIcon = [System.Windows.MessageBoxImage]::$Icon
[System.Windows.MessageBox]::Show($Message,$Title,$ButtonType,$MessageIcon)
}
}