Hey everyone!
I'm currently working on a PowerShell script that I'm pretty proud of, especially since I'm just starting out and using a bit of AI to help along the way. It runs perfectly in the PowerShell shell, but I ran into some issues after compiling it with ps2exe. Some of the functions aren't working as expected anymore. Does anyone have suggestions on how I can ensure that it works the same in both the shell and as an executable? Thanks in advance!
3 Answers
It might help to avoid converting your script to an .exe, especially since it's a beginner script. Compiling can introduce risks and isn't always necessary for small tasks. Also, if your functions are not defined correctly, they might not run as expected when compiled. Try providing more context or code in your original post so we can help you better!
It's tough to say what's going wrong without seeing your actual code. One thing to keep in mind is that sometimes tools like ps2exe can produce results that are flagged by antivirus software. Make sure to check your script for any potential issues and consider whether you really need to compile it into an executable in the first place.
You should definitely check your logs after running the script. If your script doesn't currently have logging, that's a good place to start. Also, remember to run your script in a terminal rather than the ISE, as that can cause issues, too. Using 'Start-Transcript' can help capture output and errors as well!

Thanks for the tips! I'll check my function definitions and maybe consider sticking to the script for now.