Startup.pps - Project with no forms - How to package to exe

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.
ServerbeheerRail
Posts: 5
Joined: Tue Dec 08, 2020 2:01 am

Startup.pps - Project with no forms - How to package to exe

Post by ServerbeheerRail »

I use Powershell Studio 2020.

I created a new empty Project, so I have a Startup.pps file (BuildOrder 0). I only have .ps1 files and no .psf files.

I added 4 .ps1 files:
1. MainScript.ps1 (BuildOrder 1)
2. Repository.ps1 (BuildOrder 2)
3. Functions_Email.ps1 (BuildOrder 3)
4. Functions.ps1 (BuildOrder 4)

The .ps1 files 2,3 and 4 are dot sourced into the main script.

I want to package the project into an executable, but I can't find how to configure the Startup.pps file to start the main script.
I tried to use a Collection Project, but then there is no option to package the files into an executable. Starting the main script in the collection project works fine.
by brittneyr » Wed Jan 13, 2021 8:24 am
When you created an empty project, it should have come with a Startup.pss file with a Main function. From there, you would need to call a function in your MainScript.ps1 to start your process (depending on how you have it set up). Basically, whatever logic is needed to start your main script in the Main function in Startup.pss.

A collection project is just a collection of scripts that don't necessarily connect so I would not recommend this template for you.
Go to full post

User avatar
brittneyr
Site Admin
Posts: 637
Joined: Thu Jun 01, 2017 7:20 am
Answers: 8
Been upvoted: 6 times

Re: Startup.pps - Project with no forms - How to package to exe

Post by brittneyr »

When you created an empty project, it should have come with a Startup.pss file with a Main function. From there, you would need to call a function in your MainScript.ps1 to start your process (depending on how you have it set up). Basically, whatever logic is needed to start your main script in the Main function in Startup.pss.

A collection project is just a collection of scripts that don't necessarily connect so I would not recommend this template for you.
Brittney Ryn
SAPIEN Technologies, Inc.