look mom! no winforms - creating graphical powershell alternatives

Post on 12-Jul-2015

610 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

jhicks@jdhitsolutions.com

@jeffhicks

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

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

Popup Return Values

OK 1

Cancel 2

Abort 3

Retry 4

Ignore 5

Yes 6

No 7

New-Popup.ps1

InputBox

Use VisualBasicInputBoxmethod

Define a message

Define a title

Define a default value

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

New-Inputbox.ps1

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

New-MessageBox.ps1

Out-GridView

Write objects to the pipeline in PowerShell 3.0

Select multiple or single object

Specify a title

Instant object picker

Demo-OutGridViewlist.ps1Demo-OutGridViewPicker.ps1

Putting it all together…

Thank You

http://jdhitsolutions.com/blog

jhicks@jdhitsolutions.com

@JeffHicks

http://gplus.to/jeffhicks

top related