Show-Popup.ps1
<#PSScriptInfo .VERSION 1.0.1 .GUID 31a8ab65-dbdb-45d6-986a-4926cf1784cd .AUTHOR Jordan CHERKI .DESCRIPTION This script allows to display a Pop-up to the user with differents information. .COMPANYNAME .COPYRIGHT .TAGS .LICENSEURI .PROJECTURI .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES .PRIVATEDATA #> <# .SYNOPSIS Allow to display a Pop-up to the user. .DESCRIPTION This script allows to display a Pop-up to the user with differents information. .NOTES File Name : Show-Popup.ps1 Author : Jordan CHERKI, cherkijordan@yahoo.fr Date : 2018/19/04 Version : 1.0.0 .EXAMPLE Show-Popup -Message "Do you want continue ?" -Title "Check Answer" -ButtonType YESorNO -LogoType Question -ReturnValue Yes .PARAMETER Message : Message of the Pop-up. (Mandatory) Title : Title of the Pop-up. (Optional) ButtonType : Button type displayed on the Pop-up ("OK" or "Yes or No"). (Optional) LogoType : Logo type displayed on the Pop-up. (Optional) ReturnValue : Allow to return the result of the user. (Mandatory) #> Param ( [Parameter(Mandatory=$true)] $Message, [Parameter(Mandatory=$false)] $Title = "Popup", [Parameter(Mandatory=$false)] [ValidateSet("OK","YESorNO")] $ButtonType = "OK", [Parameter(Mandatory=$false)] [ValidateSet("Information","Question","Warning","Error")] $LogoType = "Information", [Parameter(Mandatory=$true)] [ValidateSet("Yes","No")] $ReturnValue ) Add-Type -AssemblyName System.Windows.Forms Switch ($ButtonType) { "OK" {$Button = 0} "YESorNO" {$Button = 4} } Switch ($LogoType) { "Information" {$Logo = 64} "Question" {$Logo = 48} "Warning" {$Logo = 32} "Error" {$Logo = 16} } If($ReturnValue -eq "Yes") { [System.Windows.Forms.MessageBox]::Show($Message,$Title,$Button,$Logo) } Else { [System.Windows.Forms.MessageBox]::Show($Message,$Title,$Button,$Logo) | Out-Null } |