Top Banner
Look Mom, No Winforms (or WPF): Graphical Alternatives Jeff Hicks [email protected] @jeffhicks
13

Look Mom! No WinForms - Creating Graphical PowerShell Alternatives

Jul 12, 2015

Download

Technology

Jeffery Hicks
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives

Look Mom, No Winforms (or WPF): Graphical AlternativesJeff Hicks

[email protected]

@jeffhicks

Page 2: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives

Look at Me!

IT Pros love PowerShell

Everybody loves a GUI

Adding Windows Forms or WPF can be complicated

Depending on your need there are simple graphical alternatives

Page 3: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives

Wscript Popup

Don’t forget your VBScript past

Create a wscript.shellCOM object

Invoke Popup() method

Great for message display

Title

Icon

Button set

Can automatically dismiss on a

timeout value

..or force user to click a button

Page 4: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives

Popup Return Values

OK 1

Cancel 2

Abort 3

Retry 4

Ignore 5

Yes 6

No 7

Page 5: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives

New-Popup.ps1

Page 6: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives

InputBox

Use VisualBasicInputBoxmethod

Define a message

Define a title

Define a default value

$r=[microsoft.visualbasic.interaction]::InputBox($message,$title,$default)

Page 7: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives

New-Inputbox.ps1

Page 8: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives

MsgBox

Use VisualBasic MsgBox method

Same buttons and icons as Wscript.Shell Popup

User must click a button

Buttons send button text to the pipeline

Page 9: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives

New-MessageBox.ps1

Page 10: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives

Out-GridView

Write objects to the pipeline in PowerShell 3.0

Select multiple or single object

Specify a title

Instant object picker

Page 11: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives

Demo-OutGridViewlist.ps1Demo-OutGridViewPicker.ps1

Page 12: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives

Putting it all together…

Page 13: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives

Thank You

http://jdhitsolutions.com/blog

[email protected]

@JeffHicks

http://gplus.to/jeffhicks