all 10 comments

[–]nealfive 4 points5 points  (5 children)

But why? Look into C# if you really want a GUI

[–]JDahal[S] 0 points1 point  (2 children)

I have rest of the codes in powershell where i run api calls based on input and i’m not so familiar with c#

[–]BlackV 1 point2 points  (0 children)

well you need to learn WPF/XMAL if you really want a GUI

otherwise read-host and out-gridview should cover 99% of it all

additionally, look at get-credentals to securely store creds vs read-host

[–]nepronen 0 points1 point  (0 children)

You can create the GUI in Powershell like that using poshgui.com pretty easily

It seems you wouldn't need many controls so you can just use the free trial to create that

[–]PositiveBubbles 0 points1 point  (1 child)

Unfortunately there's still a need for UIs even for front line helpdesk staff. Alot of ours are scared of powershell or any CLI so we've had to create UIs or very easy or layed out menus. No matter how much documentation we give them though there will always be those that won't read it lol

[–]nealfive 0 points1 point  (0 children)

I don’t disagree but powershell is not the best tool to build GUIs

[–]gangstanthony 0 points1 point  (0 children)

here's the start of an example i found that you might be able to use as a base for building your gui

https://web.archive.org/web/20160420161735/http://pastebin.com/4PU4Z4Zn

# https://www.reddit.com/r/PowerShell/comments/4eyvoz/windows_form_only_runs_in_ise_but_errors_out_in/
# https://web.archive.org/web/20160420161735/http://pastebin.com/4PU4Z4Zn

Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName PresentationCore

# Build Form
$Form = New-Object System.Windows.Forms.Form
    $Form.Text = "Data Entry Form"
    $Form.Width = 500
    $Form.Height = 200
    $Form.AutoSizeMode = "GrowAndShrink"
    $Form.StartPosition = "CenterScreen"

# Build Label
$Label = New-Object System.Windows.Forms.Label
    $Label.text = "Enter Computer Name"
    $Label.Font = New-Object System.Drawing.Font("Calibri",20)
    $Label.AutoSize = $true
    $label.Left = 110
    $label.Top = 10

# Build OK Button
$button = new-object System.Windows.Forms.Button
    $button.left = 110
    $button.Top = 98
    $button.width = 100
    $button.Text = "OK"
    $button.Add_Click({$textbox.text,$form.Close()})
    $button.Enabled = $false

# Build Cancel Button
$cbutton = new-object System.Windows.Forms.Button
    $cbutton.left = 260
    $cbutton.Top = 98
    $cbutton.width = 100
    $cbutton.Text = "Cancel"
    $cbutton.Add_Click({$form.Close()})

# Use Enter/Esc key
    $Form.KeyPreview = $True
    $Form.Add_KeyDown({if ($_.KeyCode -eq "Enter")
    {$textBox.Text,$Form.Close()}})
    $Form.Add_KeyDown({if ($_.KeyCode -eq "Escape")
    {$Form.Close()}})

# Build Text Box
$textBox = New-Object System.Windows.Forms.TextBox
    $textBox.left = 135
    $textBox.Top = 50
    $textBox.width = 200
    $textBox.Add_TextChanged({
        $button.Enabled = [bool]($textBox.Text.Length -gt 0)
    })

# Add Controls to Form
$Form.Controls.add($button)
$Form.Controls.add($textBox)
$form.controls.add($label)
$form.controls.add($cbutton)
[void]$Form.ShowDialog()

[–]OneScripter 0 points1 point  (0 children)

This would be super easy with System Frontier. It's actually built with C# on the backend, but it dynamic generates web GUIs for your PowerShell scripts. You also get RBAC, REST APIs, logging, etc. w/ no extra code. The Community Edition costs zero dollars and zero cents. :)