Create Input Box PowerShell
If you write script for your help desk or non-initiated PowerShell people, you might want to simplify the PowerShel tools you provide to them. You may still need them to input a username or a mail address as input for your script to run only on a targeted user/mailbox.
Create Input Box PowerShell – Old way
There is a way to create an input box in PowerShell and then use the content inserted in it in your script.
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null $User = [Microsoft.VisualBasic.Interaction]::InputBox('Enter a user name', 'User', "$env:UserName")
You may noticed the “LoadWithPartialName” static method which is obsolete :
Create Input Box PowerShell – New way
The new way of loading assembly os with “Add-Type” cmdlet, so here we go :
Add-Type -AssemblyName Microsoft.VisualBasic $User = [Microsoft.VisualBasic.Interaction]::InputBox('Enter a user name', 'User', "$env:UserName")
Once the help desk guy clicked on “Ok”, the $User variable will contain the value that was in the textbox, and then you can apply some regex/validation on it, and then use it to act on Active Directory account or mailboxes.
You can combine this with a precedent article of mine, and then build some basic Graphical User Interface (GUI) for your help desk users.
You can also checkout my GUI tag to find more way to build GUI with PowerShell.