look mom! no winforms - creating graphical powershell alternatives
TRANSCRIPT
![Page 2: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives](https://reader034.vdocuments.mx/reader034/viewer/2022052413/55a20a131a28ab9b368b4630/html5/thumbnails/2.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052413/55a20a131a28ab9b368b4630/html5/thumbnails/3.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052413/55a20a131a28ab9b368b4630/html5/thumbnails/4.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052413/55a20a131a28ab9b368b4630/html5/thumbnails/5.jpg)
New-Popup.ps1
![Page 6: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives](https://reader034.vdocuments.mx/reader034/viewer/2022052413/55a20a131a28ab9b368b4630/html5/thumbnails/6.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052413/55a20a131a28ab9b368b4630/html5/thumbnails/7.jpg)
New-Inputbox.ps1
![Page 8: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives](https://reader034.vdocuments.mx/reader034/viewer/2022052413/55a20a131a28ab9b368b4630/html5/thumbnails/8.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052413/55a20a131a28ab9b368b4630/html5/thumbnails/9.jpg)
New-MessageBox.ps1
![Page 10: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives](https://reader034.vdocuments.mx/reader034/viewer/2022052413/55a20a131a28ab9b368b4630/html5/thumbnails/10.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052413/55a20a131a28ab9b368b4630/html5/thumbnails/11.jpg)
Demo-OutGridViewlist.ps1Demo-OutGridViewPicker.ps1
![Page 12: Look Mom! No WinForms - Creating Graphical PowerShell Alternatives](https://reader034.vdocuments.mx/reader034/viewer/2022052413/55a20a131a28ab9b368b4630/html5/thumbnails/12.jpg)
Putting it all together…