Support Forums

Different script execution between GUI and Non-GUI

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.
User avatar
SanSiets
Posts: 7
Joined: Tue Feb 14, 2017 6:28 am

Different script execution between GUI and Non-GUI

Postby SanSiets » Mon Jun 19, 2017 4:10 am

Hi all,

I have a script:
$creds = Get-Credential
Login-AzureRmAccount -Credential $creds -ServicePrincipal -TenantId 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
$VMname = "xx-xx-xxxxx"
$ResourceGroupName = "xxxxxx"
Start-AzureRmVm -ResourceGroupName $ResourceGroupName -Name $VMname

This script runs fine as a script and my VMware machine is started. But when I use the exact same code in the GUI it doesn't work. I don't get an error, script just freezes.

Hope that someone has a solution for this.

Greetings,
Sander
User avatar
jvierra
Posts: 10947
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Different script execution between GUI and Non-GUI

Postby jvierra » Mon Jun 19, 2017 11:12 am

Can you post a sample of the code that fails?
User avatar
SanSiets
Posts: 7
Joined: Tue Feb 14, 2017 6:28 am

Re: Different script execution between GUI and Non-GUI

Postby SanSiets » Wed Jun 21, 2017 3:19 am

Hi jvierra,

The code is in my original post.
User avatar
jvierra
Posts: 10947
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Different script execution between GUI and Non-GUI

Postby jvierra » Wed Jun 21, 2017 3:23 am

Have you stepped through with the debugger to see where it is hanging?
How are you running it in the form? Is it a button or some other control or event?

Return to “PowerShell GUIs”

Who is online

Users browsing this forum: No registered users and 2 guests