Need help with a ShowUI menu for PowerCLI.

Nov 5, 2013 at 6:55 AM
I'm trying to create a ShowUI menu for creatin' VM's.
Can anyone help me out, because i don't know where to start.

VMName: <default>
Template: <needs to be drop down menu> =(get-template)
Cores: <needs to be drop down menu> = 1,2,4,6,8
CPU: <needs to be drop down menu> = 2GB,4GB,8GB,16GB,32GB
HDD: <default>

Can anyone help me out?
Coordinator
Nov 5, 2013 at 4:04 PM
Don't you mean a combo-box dropdown?
Nov 5, 2013 at 6:51 PM
Yes can you help me out please.
Coordinator
Nov 7, 2013 at 6:31 PM
Edited Nov 7, 2013 at 6:40 PM
I can ... but this is pretty basic stuff you should be able to work out from the samples ;-)

For what it's worth, the -Margin parameter are just because I like how it looks, and if you use a UniformGrid instead of a Grid, you can get a very similar look without having to specify all the Column/Row parameters at all...
Grid -Columns "110","*" -MinWidth 260 -Rows 6 {
    Label "VMName" -Target VMName -Row 0
        TextBox -Name VMName -Column 1 -Row 0 -Margin "5,2,5,2"

    Label "Template" -Target Template -Row 1
        ComboBox -Name Template -Items (<#Get-Template#> 1,2,3) -Column 1 -Row 1 -Margin "5,2,5,2"

    Label "Cores" -Target Cores -Row 2
        ComboBox -Name Cores -Items 1,2,4,6,8 -Column 1 -Row 2 -Margin "5,2,5,2"

    Label "CPU" -Target CPU -Row 3
        ComboBox -Name CPU -Items "2GB","4GB","8GB","16GB","32GB" -Column 1 -Row 3 -Margin "5,2,5,2"

    Label "HDD" -Target HDD -Row 4
        TextBox -Name HDD  -Column 1 -Row 4 -Margin "5,2,5,2"

    Button "OK" -IsDefault -Column 1 -Row 5 -Margin "5,2,5,2" -On_Click { Set-UIValue $window; $window.Close() }
} -show

Marked as answer by Jaykul on 11/14/2013 at 2:55 PM
Nov 11, 2013 at 6:13 AM
Thank you very much. One question how can i get the output posted?
Coordinator
Nov 11, 2013 at 9:43 PM
The output will be returned to the pipeline when the window is closed -- you can assign it to a variable or pipe it to your New-VM* function or whatever, just like the output of any other command.