Not able to use PS1ExeWrapper.ps1

Jun 12, 2011 at 3:22 PM



I am not able to use PS1ExeWrapper.ps1 to make the powershell code to an exe file.


The following error is coming while using.


PS C:\scripts> .\Make-PS1ExeWrapper.ps1 .\test.ps1 .\test.exe .\arp.ico

C:\scripts\Make-PS1ExeWrapper.ps1 :   

357:    Unexpected character '-'   

410:    Unexpected character '`'   

410:    Unexpected character '''

At line:1 char:25

+ .\Make-PS1ExeWrapper.ps1 <<<<  .\test.ps1 .\test.exe .\arp.ico   

+ CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException   

+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Make-PS1ExeWrapper.ps1


Can you please look and help me in resolving this issue ?



Naga Suresh


Jun 12, 2011 at 7:24 PM

Just to clarify, Make-PSExeWrapper is not a part of PSCX.  It is a sample I posted on my blog about how to wrap a PS1 file as a resource within an exe such that the exe extracts the script at runtime and executes the script in a runspace.  The most likely problem is that when you copy/paste PowerShell script from someplace and that PowerShell script uses line continuations (ie ` char), you have to make sure that are NO spaces after any line continuation char.   Otherwise you will get errors like the ones you're seeing.