Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a problem #140

Open
heilingbrunner opened this issue Dec 5, 2024 · 2 comments
Open

Fixed a problem #140

heilingbrunner opened this issue Dec 5, 2024 · 2 comments

Comments

@heilingbrunner
Copy link

heilingbrunner commented Dec 5, 2024

Hi,

when i used Invoke-ps2exe with arguments, it failed with a message 'cmd-let Invoke-ps2exe not found ...'. Using only Invoke-ps2exe showed the help text correctly. I solved the problem adding an 'Import-Module ...; statement before the recursive 'Invoke-ps2exe' command inside of the function. This imports your module in the new started session and fixed my problem.

function Invoke-ps2exe
{
        ...

	if (!$nested -and ($PSVersionTable.PSEdition -eq "Core"))
	{ 

               ...

		$CallParam += " -nested"

		$commandname = $($MyInvocation.MyCommand.Name)
                $modulePath = "$PSScriptRoot\ps2exe.psm1"
                $command = "Import-Module '$modulePath'; & '$commandname' $CallParam"

                Write-Host "Executing new session: $command"

                # Execute the command in a new Windows PowerShell process
                powershell -Command $command
        
		return
     
       ...

Please check if this is a correct fix.

Thank you.

@elijsearle
Copy link

I had the same issue. Worked for me as well

@MScholtes
Copy link
Owner

Hello @heilingbrunner,

as PS2EXE is made for Windows Powershell and not for Powershell Core, it was never my focus to get it running in a Core environment. But your approach seems to be a good idea.

I will make some tests.

Greetings

Markus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants