MsgBox Execution Query

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.
Locked
yeknidapsa
Posts: 1
Joined: Sat May 30, 2020 6:11 am

MsgBox Execution Query

Post by yeknidapsa »

Hi, I have to put a msgbox showing if the order beneath was executed effectively or not

$buttonGrant_Click={
#$GroupTest = $textboxCheckGroup.Text
$textboxResultado.Lines = Add-ADGroupMember -Identity $textboxGroup.Text -Members $textboxLogin.Text
}

For example:
In the event that the order execute effectively shows the msg in the popup: 'Access Released'
On the off chance that the client as of now has bunch get to, show the msg in the popup: 'Client as of now has bunch access'
In the event that the order doesn't execute effectively, shows the msg in the popup: 'Order not executed, check the information entered.

Regards,
Grady M Kidwell

jvierra
Posts: 14480
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: MsgBox Execution Query

Post by jvierra »

Hi. To do that you would need to use Try/CAtch to detect the error then use [System.Windows.Forms.Messagebox]::Show('your message here')

See:
https://info.sapien.com/index.php/guis/ ... ox-control
https://docs.microsoft.com/en-us/powers ... wershell-7

User avatar
kellam
Posts: 5
Joined: Tue Jun 02, 2020 8:59 am

Re: MsgBox Execution Query

Post by kellam »

Is there a way to make both modal window and the parent form enabled at the same time?

jvierra
Posts: 14480
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: MsgBox Execution Query

Post by jvierra »

No. That is what "modal" means. A child form is modal to the parent. The parent is not executing. This is a limitation of forms in PowerShell due to the threading capability.

You can open a form in a new runspace and it will be modeless to the parent form as it runs in a new thread (runspace).

Locked