From 92b43b5fdbd190eaa84edc56285124da9ce12590 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Fri, 9 Aug 2019 17:01:32 +0200 Subject: [PATCH] Added first type of GUI --- .../ConvertTo-Base64GUIExample.ps1 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ConvertTo-Base64GUIExample/ConvertTo-Base64GUIExample.ps1 b/ConvertTo-Base64GUIExample/ConvertTo-Base64GUIExample.ps1 index 60aa38c..0491250 100644 --- a/ConvertTo-Base64GUIExample/ConvertTo-Base64GUIExample.ps1 +++ b/ConvertTo-Base64GUIExample/ConvertTo-Base64GUIExample.ps1 @@ -7,8 +7,16 @@ Function to showcase some of the PowerShell GUI capabilities This function contains various examples of using the GUI capabilities of both Windows PowerShell and PowerShell (Core). This is inteded to be used as a reference for those interested in building basic GUIs with PowerShell #> - [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null - $InputBox = [Microsoft.VisualBasic.Interaction]::InputBox("Let's convert this to base64", "Sabrina's App", $null) - $InputBox = [convert]::ToBase64String([char[]]$InputBox) - [Microsoft.VisualBasic.Interaction]::MsgBox($InputBox,0,"Sabrina's App") +param( + [string] $Title, + [validateset('VB')] + [string] $GUIType = 'VB' +) + + if ('VB' -eq $GUIType) { + [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null + $InputBox = [Microsoft.VisualBasic.Interaction]::InputBox("Let's convert this to base64", $Title, $null) + $InputBox = [convert]::ToBase64String([char[]]$InputBox) + [Microsoft.VisualBasic.Interaction]::MsgBox($InputBox,0,$Title) + } } \ No newline at end of file