Deployment N00b!

Ask your PowerShell-related questions, including questions on cmdlet development!
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 1 year and 9 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
proshot78
Posts: 14
Last visit: Wed Aug 09, 2023 3:39 pm
Answers: 1
Has voted: 3 times

Deployment N00b!

Post by proshot78 »

Good afternoon!

I have a fairly strong grasp of Powershell itself, but I cannot for the life of me figure out how to get a standalone exe to work using deployment (primarily because I don't have experiences building packages. Does anyone have resources I can look into to educate myself on this?
by Alexander Riedel » Sat May 21, 2022 11:45 pm
I am sure you realized that the files don't actually exist in the folders indicated. The executable resulting from packaging is not created in the same folder as your original script. So you have to copy/move any auxiliary files relative to where the executable is.
https://www.sapien.com/blog/2009/09/02/ ... nvocation/ may help you locate the location of your application whether it is a script or packaged.
Depending on your needs, the data requiring to be modified during application sessions or not, it might be advisable to place your data in a location that is easily 'calculated' by either script or packaged executable.
For Example:
C:\ProgramData\<Your Application>\User Account Tools\Common
might be a good location.
If your data is per user rather than per machine
C:\Users\<User>\AppData\Roaming\<Your Application>\User Account Tools\Common
would be a better choice
Go to full post
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Deployment N00b!

Post by jvierra »

I would suggest clicking the link in PSS for the documentation and reading how the builder and deployer work which will give you all of the options available and fair explanation of how to build and deploy an EXE with examples.

Read the following carefully and do the examples. https://info.sapien.com/manuals/powersh ... ckage.html

Once you see it it is very simple and easy.
proshot78
Posts: 14
Last visit: Wed Aug 09, 2023 3:39 pm
Answers: 1
Has voted: 3 times

Re: Deployment N00b!

Post by proshot78 »

I managed to get an exe file, but it doesn't seem to be able to see my module & supporting files. I did check the option for 'resolve and include external scripts'. What else am I missing here?
User avatar
Alexander Riedel
Posts: 8472
Last visit: Tue Mar 19, 2024 12:32 am
Answers: 19
Been upvoted: 37 times

Re: Deployment N00b!

Post by Alexander Riedel »

You will have to be more specific. External scripts means dot sourced scripts. Modules cannot be resolved and packaged, that would defeat the purpose of a module. Not sure what you mean by it cannot 'see' them.
Generally, it is best to provide the code you use to access something and the resulting error message.
Alexander Riedel
SAPIEN Technologies, Inc.
proshot78
Posts: 14
Last visit: Wed Aug 09, 2023 3:39 pm
Answers: 1
Has voted: 3 times

Re: Deployment N00b!

Post by proshot78 »

Here is the errors produced when attempting to run the executable:
  1. Get-Content:
  2. Line |
  3.   72 |  … bal:FacilityInfo = Get-Content .\Common\FacilityMappings.json | Conve …
  4.      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5.      | Cannot find path 'C:\Users\amclay\Documents\SAPIEN\PowerShell Studio\Projects\User Account Tools\bin\x64\User Account Tools\Common\FacilityMappings.json' because it does not exist.
  6. Get-Content:
  7. Line |
  8.   73 |      $Global:UATSettings = Get-Content .\Common\Settings.json | Conver …
  9.      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  10.      | Cannot find path 'C:\Users\amclay\Documents\SAPIEN\PowerShell Studio\Projects\User Account Tools\bin\x64\User Account Tools\Common\Settings.json' because it does not exist.
  11. Import-Module:
  12. Line |
  13.   76 |      Import-Module .\Common\UserToolsFunctions.psm1 -Force
  14.      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15.      | The specified module '.\Common\UserToolsFunctions.psm1' was not loaded because no valid module file was found in any module directory.
Here's the section of code where it's failing:
  1.    
  2.         $Global:FacilityInfo = Get-Content .\Common\FacilityMappings.json | ConvertFrom-Json
  3.     $Global:UATSettings = Get-Content .\Common\Settings.json | ConvertFrom-Json
  4.     Import-Module .\Common\UserToolsFunctions.psm1 -Force
User avatar
Alexander Riedel
Posts: 8472
Last visit: Tue Mar 19, 2024 12:32 am
Answers: 19
Been upvoted: 37 times

Re: Deployment N00b!

Post by Alexander Riedel »

I am sure you realized that the files don't actually exist in the folders indicated. The executable resulting from packaging is not created in the same folder as your original script. So you have to copy/move any auxiliary files relative to where the executable is.
https://www.sapien.com/blog/2009/09/02/ ... nvocation/ may help you locate the location of your application whether it is a script or packaged.
Depending on your needs, the data requiring to be modified during application sessions or not, it might be advisable to place your data in a location that is easily 'calculated' by either script or packaged executable.
For Example:
C:\ProgramData\<Your Application>\User Account Tools\Common
might be a good location.
If your data is per user rather than per machine
C:\Users\<User>\AppData\Roaming\<Your Application>\User Account Tools\Common
would be a better choice
Alexander Riedel
SAPIEN Technologies, Inc.
proshot78
Posts: 14
Last visit: Wed Aug 09, 2023 3:39 pm
Answers: 1
Has voted: 3 times

Re: Deployment N00b!

Post by proshot78 »

I finally have it figured out, I stopped trying to run the exe from bin and used a MSI installer to install everything to program files.
Some functions in my scripts are behaving differently than they do in the editor, but that's a problem for a different thread.

Thank you all for your assistance!
This topic is 1 year and 9 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