MScholtes / PS2EXE

Module to compile powershell scripts to executables
Other
1.21k stars 198 forks source link

Module Initialize Error on 24h2 #137

Open zoicware opened 1 week ago

zoicware commented 1 week ago

I have converted a powershell script to an exe inside of this script another powershell script runs that imports a module with functions. When running any functions in this module that have "Get-AppxPackage" in them an error happens image

If I use the script without converting to an exe everything works normally

MScholtes commented 6 days ago

Hello @zoicware,

I guess the error has something to do with Powershell Core. What version of Powershell do you use to compile the script with PS2EXE - PS2EXE works only with Powershell 5.x. How do you call the second Powershell script and what module fails and how and where do you load it? Does this script work on a pre 24h2 computer?

Greetings

Markus

zoicware commented 6 days ago

Im using 5.1 Yes it works on any other version except for 24h2. I was able to fix it by just switching the script to batch and compiling that to an exe (code here - https://github.com/zoicware/ZOICWARE/blob/main/src/RUN%20ZOICWARE.bat) This was compiled with the bat2exe tool (Win32 Cabinet Self-Extractor file)

Ill try to summarize the workflow RUN ZOICWARE is ran which then searches for zoicware.ps1 and runs this script like &$script, then that script sets up some things like importing a module in order to use the functions from it. When running any function from this module that has get-appxpackage the error happens as well as any other script ran from this powershell compiled exe.

MScholtes commented 5 days ago

Hello @zoicware,

I still cannot reproduce your error. But you seem to have found a solution - that's fine.

Greetings

Markus