Page 1 of 1

Deployment N00b!

Posted: Fri May 20, 2022 6:32 pm
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?

Re: Deployment N00b!

Posted: Fri May 20, 2022 7:40 pm
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.

Re: Deployment N00b!

Posted: Sat May 21, 2022 4:42 pm
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?

Re: Deployment N00b!

Posted: Sat May 21, 2022 5:00 pm
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.

Re: Deployment N00b!

Posted: Sat May 21, 2022 5:22 pm
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

Re: Deployment N00b!

Posted: Sat May 21, 2022 11:45 pm
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

Re: Deployment N00b!

Posted: Sun May 22, 2022 3:38 pm
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!