Sometimes it’s better to prepare user interface for Powershell scripts. In the post ‘3 scenarios when you should add GUI to Powershell script‘ I wrote when you should think about this. In this post, I want to show you more technical knowledge about basics GUI elements in Powershell. If you have never programmed, you can learn from this article about many types of GUI elements, which are similar in other programming languages. All programming languages have a different way to prepare graphical user interface, but parts are comparable. If you understand this in Powershell, I’m sure that you will understand it in other programming languages too. Before I started list GUI elements, I have to tell you that I’m not frontend developer so if you find some mistakes please let me know in comments.

I don’t like reinventing the wheel. I want to show you a great tool which helps you create GUI faster, and you will save time. You can find out this tool at It allows you to prepare the graphical user interface in the drag-and-drop model. As a result, you will receive the Powershell code with this GUI.

user interface for powershell

17 user interface elements


A textbox element is a place where you can write some text. It can be used for reading value for script parameter.

user interface for powershell


I think that it’s clear 🙂 It’s nothing else like button which you can use to invoke some Powershell script or function.

user interface for powershell


The label is an element which you can use for the labeling some parts of your user interface.

user interface for powershell


You can use the checkbox element to list some script option and check it before Powershell script run.

user interface for powershell


Listbox stores several text items.

user interface for powershell


Radiobutton is similar to checkbox but it operates as a group and user can choose only one of the available options.

user interface for powershell


DataGridView allows you to view tabular data.

user interface for powershell


Below you can check all code generated by PoshGUI and see how it works after run in Powershell console.

<# This form was created using  a free online gui designer for PowerShell

Add-Type -AssemblyName System.Windows.Forms

$Form                            = New-Object system.Windows.Forms.Form
$Form.ClientSize                 = '575,541'
$Form.text                       = "Form"
$Form.TopMost                    = $false

$TextBox1                        = New-Object system.Windows.Forms.TextBox
$TextBox1.multiline              = $false
$TextBox1.width                  = 100
$TextBox1.height                 = 20
$TextBox1.location               = New-Object System.Drawing.Point(11,47)
$TextBox1.Font                   = 'Microsoft Sans Serif,10'

$Button1                         = New-Object system.Windows.Forms.Button
$Button1.text                    = "button"
$Button1.width                   = 60
$Button1.height                  = 30
$Button1.location                = New-Object System.Drawing.Point(145,40)
$Button1.Font                    = 'Microsoft Sans Serif,10'

$Label1                          = New-Object system.Windows.Forms.Label
$Label1.text                     = "label"
$Label1.AutoSize                 = $true
$Label1.width                    = 25
$Label1.height                   = 10
$Label1.location                 = New-Object System.Drawing.Point(19,20)
$Label1.Font                     = 'Microsoft Sans Serif,10'

$CheckBox1                       = New-Object system.Windows.Forms.CheckBox
$CheckBox1.text                  = "checkBox"
$CheckBox1.AutoSize              = $false
$CheckBox1.width                 = 95
$CheckBox1.height                = 20
$CheckBox1.location              = New-Object System.Drawing.Point(8,90)
$CheckBox1.Font                  = 'Microsoft Sans Serif,10'

$CheckBox2                       = New-Object system.Windows.Forms.CheckBox
$CheckBox2.text                  = "checkBox"
$CheckBox2.AutoSize              = $false
$CheckBox2.width                 = 95
$CheckBox2.height                = 20
$CheckBox2.location              = New-Object System.Drawing.Point(6,124)
$CheckBox2.Font                  = 'Microsoft Sans Serif,10'

$ListBox1                        = New-Object system.Windows.Forms.ListBox
$ListBox1.text                   = "listBox"
$ListBox1.width                  = 176
$ListBox1.height                 = 83
@('Item1','Item2','Item3') | ForEach-Object {[void] $ListBox1.Items.Add($_)}
$ListBox1.location               = New-Object System.Drawing.Point(12,157)

$RadioButton1                    = New-Object system.Windows.Forms.RadioButton
$RadioButton1.text               = "radioButton"
$RadioButton1.AutoSize           = $true
$RadioButton1.width              = 104
$RadioButton1.height             = 20
$RadioButton1.location           = New-Object System.Drawing.Point(223,150)
$RadioButton1.Font               = 'Microsoft Sans Serif,10'

$RadioButton2                    = New-Object system.Windows.Forms.RadioButton
$RadioButton2.text               = "radioButton"
$RadioButton2.AutoSize           = $true
$RadioButton2.width              = 104
$RadioButton2.height             = 20
$RadioButton2.location           = New-Object System.Drawing.Point(225,190)
$RadioButton2.Font               = 'Microsoft Sans Serif,10'

$DataGridView1                   = New-Object system.Windows.Forms.DataGridView
$DataGridView1.width             = 300
$DataGridView1.height            = 250
$DataGridView1.location          = New-Object System.Drawing.Point(26,264)


user interface for powershell


As you can see, when you want to build your first graphical user interface for a Powershell script, you have to learn about elements which you can use. Next step is to use them together, send data from user interface to your Powershell script and send back from Powershell script to GUI.

Do you know more GUI elements which are also important to know?

Get Access to Poshland Resources for FREE!!!

Signup now and receive an email once I publish new content.

I agree to have my personal information transfered to MailChimp ( more information )

I will never give away, trade or sell your email address. You can unsubscribe at any time.

Damian Garbus

Hi, My name is Damian. I'm Powershell geek. Also, I love to improve my productivity and yourself development. I connected Powershell and my productivity tricks and built this blog. You can find here how to learn Powershell and use this to improve your productivity. Enjoy.

Leave a Reply

Your email address will not be published.