Calling powershell command using Radio Button

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 10 years and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
saukulka
Posts: 2
Last visit: Wed Jan 06, 2016 2:09 am

Calling powershell command using Radio Button

Post by saukulka »

Hi,

I am developing a script for helpdesk guys to carry out certain tasks of Office 365 Management of user/shared mailboxes.

This is what I intend to do:

1) create a GUI with 10 seperate tasks for mailbox management as radio buttons.
2) For each task, assign a radio button
3) Run a background powershell command to execute the task
4) Pull the information output from powershell command to the GUI

I managed to create the GUI with 10 seperate tasks using PrimalTools CE.
I have the powershell commands ready.

But I am unable to integrate the powershell commands to those individual radio buttons.

I am a bit new to scripting so appreciate If anyone can help me direct in the correct direction.

Thanks
Saurabh
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Calling powershell command using Radio Button

Post by jvierra »

You have to manually add the script to the 'OnChange" event of the radio button.

$radio1.add_OnChange({ #code } )

This will fire whenever to button changes.

The easy way to add is this:
PowerShell Code
Double-click the code block to select all.
$radiobutton1_CheckedChanged={
     if($this.Checked){    
          #TODO: Place custom script here	
     }
}

$radiobutton1.add_CheckedChanged($radiobutton1_CheckedChanged)
User avatar
saukulka
Posts: 2
Last visit: Wed Jan 06, 2016 2:09 am

Re: Calling powershell command using Radio Button

Post by saukulka »

Thanks for the update jvierra.

I have the script running. But there is a problem. When I run the script from Power Shell studio, the Input boxes come up as expected.

But when I run the script using powershell, the input is asked in the powershell window and not in the tool's input box.

I want to intergrate only one input box for all the queries I am running in the tool.

Any ideas you can share for this?

Thanks in advance for your help.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Calling powershell command using Radio Button

Post by jvierra »

There are no input boxes in the code I posted so I do not know what you are talking about.

There is no reason for an export to be any different from running in PS2012
This topic is 10 years and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked