Trigger button by code?

Ask your PowerShell-related questions, including questions on cmdlet development!
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 11 years and 1 month 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
dping28
Posts: 52
Last visit: Thu May 15, 2014 5:01 pm

Trigger button by code?

Post by dping28 »

Is it possible to trigger a button by code? I have a button that executes a collection of items and I have a button already setup to do a bunch of it and instead of redoing all that code I would like to just issue something to trigger the button as if it was clicked. is this possible?

I have a button for removing Office 365 License (One I want to trigger) it does a bunch of disabling of controls as well as the obvious

I then am making a button that converts a mailbox and I need to change the quota and remove the license when its converting to a shared, trying to automate all of this with the one click.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Trigger button by code?

Post by jvierra »

Just execute the button code. A button has an assigned script block

$buttonOK_Click.Invoke()

This will execute the code associated with the button 'OK'.
User avatar
dping28
Posts: 52
Last visit: Thu May 15, 2014 5:01 pm

Trigger button by code?

Post by dping28 »

Exactly what I was looking for.. Thank you jvierra!
This topic is 11 years and 1 month 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