Start ps1-Script in a form

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 5 years and 1 week 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.
User avatar
bhnuser
Posts: 48
Last visit: Tue Nov 21, 2023 10:33 pm

Start ps1-Script in a form

Post by bhnuser »

Hello everybody,

I have received a script for my self-made tool from my colleagues and would like to incorporate it. Unfortunately I do not know how I can execute a script with a push of a button. The script as seen the attachments should be included in the project.
To open other forms i can use: Show-Exchange_psf
So my question is: How can i start a script in my project?

Best regards
Attachments
Unbenannt.PNG
Unbenannt.PNG (12.64 KiB) Viewed 2554 times
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Start ps1-Script in a form

Post by davidc »

It depends on the settings of the files in the project. To check the Build property, first select the file in the Project panel and then look the settings in the Properties panel:
Setting Build Property.png
Setting Build Property.png (21.17 KiB) Viewed 2544 times

If the ps1 Build property is set to Include and Shared = False, then you will need to use the Invoke reference function method:

Code: Select all

Invoke-FileName_ps1

If Build = Include and Shared = True, then the file is merged into the script and doesn't need to be invoked.


If the file's Build property is set to Content, then you will have to dot source the file normally:

Code: Select all

. .\Filename.ps1

The following article covers how to pass and return values in GUI and projects:

https://info.sapien.com/index.php/guis/ ... sing-forms

Note: The verbs have changes since this article was written from Call to Invoke and Show.
David
SAPIEN Technologies, Inc.
User avatar
bhnuser
Posts: 48
Last visit: Tue Nov 21, 2023 10:33 pm

Re: Start ps1-Script in a form

Post by bhnuser »

Thank you very much. It works for me now :)
This topic is 5 years and 1 week 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.