problem import ?

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

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 3 years and 2 days 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.
Canon Belgium
Posts: 8
Last visit: Tue Feb 01, 2022 2:45 am

problem import ?

Post by Canon Belgium »

Hi everybody ,

i recently bought powershell studio to improve my scripts ( i m also a beginner with powershell )
I tried to import a module like we do in powershell and it works fine ( the import )

The only thing is that when i run one of the command ( that is supposed to make a connection to a website with credentials) , it doesn't work while the command works fine when i send it from powershell ise .....

Does anybody have any idea on where it can come from ??

Since the site is a test environnment at my company , i can t share the credentials .... but i can share the imported module if necessary ....

Product, version and build: PowerShell Studio 2021 5.8.187
Operating system: Windows 2016
PowerShell version(s): powershell 5 powershell 7

ES, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
Attachments
NTware.Ufo.PowerShell.ObjectManagement.zip
(87.08 KiB) Downloaded 91 times
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: problem import ?

Post by brittneyr »

What are errors are you receiving from this command? Have you tried setting a break point on this command and debugging the script?
Brittney
SAPIEN Technologies, Inc.
Canon Belgium
Posts: 8
Last visit: Tue Feb 01, 2022 2:45 am

Re: problem import ?

Post by Canon Belgium »

Yes , i tried the breakpoints and yes i tried to debug.

It seems to block when i use one of the functions that is called "open-momoconnection" included in the module i posted.
that same command works perfectly fine when i launch it with powershell ise ...

I also tried the '-verbose' parameter without any success.... :-/
Canon Belgium
Posts: 8
Last visit: Tue Feb 01, 2022 2:45 am

Re: problem import ?

Post by Canon Belgium »

Another "strange" thing : if i make a ps1 file including the command that causes me a problem and i use :

powershell.exe .\do.ps1

then it works fine ....
Canon Belgium
Posts: 8
Last visit: Tue Feb 01, 2022 2:45 am

Re: problem import ?

Post by Canon Belgium »

:D
Canon Belgium
Posts: 8
Last visit: Tue Feb 01, 2022 2:45 am

Re: problem import ?

Post by Canon Belgium »

When i run this separately :
  1. $TenantDomain = 'training-nfr-cbe-bvandewiele.eu.uniflowonline.com'
  2. $TenantUserName = 'admin_training-nfr-cbe-bvandewiele@euaduniflow.onmicrosoft.com'
  3. $PlainPwd = 'MYPASSWORD'
  4. $SecurePwd = $PlainPwd | ConvertTo-SecureString -AsPlainText -Force
  5.  
  6. Import-Module '.\Modules\NTware.Ufo.PowerShell.ObjectManagement.dll' -Verbose
  7.  
  8. Open-MomoConnection -TenantDomain $TenantDomain -UserName $TenantUserName -Password $SecurePwd -NonInteractive -Verbose
  9.  
  10. [int32]$NBRallusers = (Find-MomoUsers).Count
  11.  
  12. Write-Output $NBRallusers
It Works FINE

When i run the same thing on the event click of a button , it doen't work ... it blocks at the command open-momoconnection

PS : my password has naturally been changed ...
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: problem import ?

Post by brittneyr »

Please try running your GUI script in STA Mode (Home->Platform):
SPS_RibbonSTAMode.png
SPS_RibbonSTAMode.png (29.65 KiB) Viewed 5901 times
Brittney
SAPIEN Technologies, Inc.
Canon Belgium
Posts: 8
Last visit: Tue Feb 01, 2022 2:45 am

Re: problem import ?

Post by Canon Belgium »

Hi ,

thanks for your answer but i already tried ...
when i launch the script by itself :
1.JPG
1.JPG (81.71 KiB) Viewed 5641 times
when i launch it from a click_button :
2.JPG
2.JPG (81.17 KiB) Viewed 5641 times

Kind Regards

Bertrand
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: problem import ?

Post by brittneyr »

Please verify that $buttonTest is subscribed to the to the click event $buttonTest_Click. This can be checked with the designer open from the properties panel's event tab:
SPS_PropertiesPanelEventTab.png
SPS_PropertiesPanelEventTab.png (20.67 KiB) Viewed 5624 times
Assuming this button is being clicked in the form for this code to run, are $TenantDoman, $TenantUserName, $PlainPwd, $SecurePwd all null?
Brittney
SAPIEN Technologies, Inc.
Canon Belgium
Posts: 8
Last visit: Tue Feb 01, 2022 2:45 am

Re: problem import ?

Post by Canon Belgium »

hi,


all the variables are defined in the file do.ps1 before the import of the module
like i said previously , when i launch the file separately , it works fine...

and to answer your other question , yes the $buttonTest is subscribed to the to the click event $buttonTest_Click

it s a bit like i can t launch the code on an event ..???
I also tried to put the code directly in the click event ( i had tried to launch the code that is in the file do.ps1 directly on the click-event)

:-/

thank you for your help
This topic is 3 years and 2 days 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.