Powershell with GUI


good afternoon,

im new powershell scripting , have managed write script launches popup box populated 2 buttons, upon selecting button run script launch selected application. works in practice while using powershell ise.

however want deliver users via citrix published application potentially running like: c:\windows\system32\windowspowershell\v1.0\powershell.exe -file menu.ps1 , when performed in manner powershell window relevant selection boxes rather application type.

script below:

$title = "welcome"
$message = "please select app"

$app1 = new-object system.management.automation.host.choicedescription "&app1", `
    "launches app1"

$app2 = new-object system.management.automation.host.choicedescription "&app2", `
    "launches app2"

$options = [system.management.automation.host.choicedescription[]]($app1, $app2)

$result = $host.ui.promptforchoice($title, $message, $options, 0)

$ps = [powershell]::create()
$ps.addscript(
     {
     [system.windows.forms.application]::run($form)
     })
$ps.runspace.sessionstateproxy.setvariable("form", $form)
$ps.begininvoke()

switch ($result)
    {
        0 {"you selected app1." | start-process c:\windows\system32\windowspowershell\v1.0\powershell.exe "scriptlocation1.ps1"}
        1 {"you selected app2." | start-process c:\windows\system32\windowspowershell\v1.0\powershell.exe "scriptlocation2.ps1"}
    }


any suggestions/assistance appreciated.

thank

there no need runspace here.

you cannot popups outside of ise.

you trying run form there no form.


\_(ツ)_/



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607