Include scripts in PowerShell GUI project

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.

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 4 years and 6 months 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
timstspry17
Posts: 45
Last visit: Tue Apr 18, 2023 2:49 pm

Include scripts in PowerShell GUI project

Post by timstspry17 »

Hello, I would like to know if in a PowerShell project you can include other scripts in like the form_load event? I would like to include a couple of scripts in the same directory as my powershell project and have their functions available to the form project like this:

.\getsomeinformation.ps1
.\getmoreinfo.ps1

so on and so forth.

Thanks!
Tim
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Include scripts in PowerShell GUI project

Post by jvierra »

Yes. Have you tried this in your form? Any scripts or modules can be loaded.
You need to use the script home folder and use the full path to the script.
User avatar
timstspry17
Posts: 45
Last visit: Tue Apr 18, 2023 2:49 pm

Re: Include scripts in PowerShell GUI project

Post by timstspry17 »

Thank you for this information. Yes, I had tried it in my form project, but didn't use the full path to the scripts. This information is helpful, thanks so much!

Tim
This topic is 4 years and 6 months 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