forked from jdhitsolutions/ISEScriptingGeek
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNew-InputBox.ps1
More file actions
50 lines (41 loc) · 1.27 KB
/
New-InputBox.ps1
File metadata and controls
50 lines (41 loc) · 1.27 KB
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
Function New-Inputbox {
<#
.Synopsis
Display a Visual Basic style inputbox.
.Description
This function will display a graphical Inputbox, like the one from VisualBasic
and VBScript. You must specify a messag prompt. You can specify a title, the
default is "Input". You can also specify a default value. The inputbox will write
whatever is entered into it to the pipeline. If you click Cancel the inputbox
will still write a string to the pipeline with a length of 0. It is recommended
that you validate input.
.Example
PS C:\> $c = New-Inputbox -prompt "Enter the Netbios name of a domain computer." -title "Enter a computername" -default $env:computername
PS C:\> get-service -computer $c
.Notes
Last Updated:
Version : 0.9
.Inputs
None
.Outputs
[string]
#>
[cmdletbinding()]
Param (
[Parameter(Position=0,Mandatory,HelpMessage="Enter a message prompt")]
[ValidateNotNullorEmpty()]
[string]$Prompt,
[Parameter(Position=1)]
[string]$Title="Input",
[Parameter(Position=2)]
[string]$Default
)
Try {
Add-Type -AssemblyName "microsoft.visualbasic" -ErrorAction Stop
[microsoft.visualbasic.interaction]::InputBox($Prompt,$Title,$Default)
}
Catch {
Write-Warning "There was a problem creating the inputbox"
Write-Warning $_.Exception.Message
}
} #end New-Inputbox