Functions Setup

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 7 years and 5 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.
User avatar
Alcasczar
Posts: 31
Last visit: Sat Jun 22, 2019 9:30 am

Functions Setup

Post by Alcasczar »

Hello, I was wondering if there's a way to configure Powershell Studio 2016 so that it imports my custom functions each time I create a new Project like a Form project or multi-form project. I didn't see any sort of setup options around that but was just curious . What I've been doing is just importing them manually.



Product, version and build: Powershell 2016
32 or 64 bit version of product: 64
Operating system: Windows 8.1 / Windows 10
32 or 64 bit OS: 64
PowerShell Version: 5 (sometimes 4)

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Functions Setup

Post by davidc »

You can accomplish this by creating your own project template.

Here are some steps to get you started (assuming the functions are in a single file):

1. Copy an existing template folder from:

C:\ProgramData\SAPIEN\PowerShell Studio 2016\Templates\Projects

2. Then paste the template folder into the User Template folder:

C:\Users\(username)\AppData\Roaming\SAPIEN\PowerShell Studio 2016\Templates\Projects

Important: Rename the template folder to prevent name confusion.

3. Paste the script file containing the function into the new template folder.

4. Edit template.xml and add the following to the files element:
  1. <File>MyFunctionFileName.ps1</File>
5. Edit the psproj file and add the following to the Files element:
  1. <File Build="0" CommandExtension="True">Globals.ps1</File>
For example:
  1. <Project>
  2.     <Version>1.1</Version>
  3.     <FileID>%ProjectIdentifier%</FileID>
  4.     <Files>
  5.         <File ReferenceName="" Build="0">Startup.pss</File>
  6.         <File ReferenceName="Call-Global_ps1" Build="0" CommandExtension="True">Globals.ps1</File>
  7.                 <File Build="0" CommandExtension="True">MyFunctionFileName.ps1</File>
  8.     </Files>
  9. </Project>
6. Then open PowerShell Studio and select the new project template from the project list.
David
SAPIEN Technologies, Inc.
User avatar
Alcasczar
Posts: 31
Last visit: Sat Jun 22, 2019 9:30 am

Re: Functions Setup

Post by Alcasczar »

That's awesome thank you very much!
This topic is 7 years and 5 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.